5
5
import com .jhl .admin .util .SimpleJpaRepositoryImpl ;
6
6
import lombok .extern .slf4j .Slf4j ;
7
7
import org .apache .commons .codec .digest .DigestUtils ;
8
- import org .springframework .beans .BeansException ;
9
- import org .springframework .beans .factory .InitializingBean ;
10
8
import org .springframework .beans .factory .annotation .Autowired ;
11
- import org .springframework .beans .factory .annotation .Value ;
12
- import org .springframework .beans .factory .config .BeanPostProcessor ;
13
9
import org .springframework .boot .SpringApplication ;
14
10
import org .springframework .boot .autoconfigure .SpringBootApplication ;
15
11
import org .springframework .context .annotation .Bean ;
16
12
import org .springframework .data .jpa .repository .config .EnableJpaRepositories ;
17
13
import org .springframework .http .HttpHeaders ;
18
- import org .springframework .http .HttpRequest ;
19
14
import org .springframework .http .MediaType ;
20
- import org .springframework .http .client .ClientHttpRequestExecution ;
21
- import org .springframework .http .client .ClientHttpRequestInterceptor ;
22
- import org .springframework .http .client .ClientHttpResponse ;
23
15
import org .springframework .scheduling .annotation .EnableAsync ;
24
16
import org .springframework .scheduling .annotation .EnableScheduling ;
25
17
import org .springframework .transaction .annotation .EnableTransactionManagement ;
26
18
import org .springframework .web .client .RestTemplate ;
27
19
28
- import javax .annotation .PostConstruct ;
29
- import java .io .IOException ;
30
20
import java .util .TimeZone ;
31
- import java .util .concurrent .*;
32
21
33
22
@ SpringBootApplication
34
23
@ EnableJpaRepositories (repositoryBaseClass = SimpleJpaRepositoryImpl .class )
@@ -49,18 +38,15 @@ public static void main(String[] args) {
49
38
50
39
51
40
@ Bean
52
- public RestTemplate restTemplate () {
41
+ public RestTemplate restTemplate (FastJsonHttpMessageConverter fastJsonHttpMessageConverter ) {
53
42
RestTemplate restTemplate = new RestTemplate ();
54
- restTemplate .getInterceptors ().add (new ClientHttpRequestInterceptor () {
55
- @ Override
56
- public ClientHttpResponse intercept (HttpRequest request , byte [] body , ClientHttpRequestExecution execution ) throws IOException {
57
- HttpHeaders headers = request .getHeaders ();
58
- headers .add ("Authorization" , DigestUtils .md5Hex (proxyConstant .getAuthPassword ()));
59
- headers .setContentType (MediaType .APPLICATION_JSON );
60
- return execution .execute (request , body );
61
- }
43
+ restTemplate .getInterceptors ().add ((request , body , execution ) -> {
44
+ HttpHeaders headers = request .getHeaders ();
45
+ headers .add ("Authorization" , DigestUtils .md5Hex (proxyConstant .getAuthPassword ()));
46
+ headers .setContentType (MediaType .APPLICATION_JSON );
47
+ return execution .execute (request , body );
62
48
});
63
- restTemplate .getMessageConverters ().add (new FastJsonHttpMessageConverter () );
49
+ restTemplate .getMessageConverters ().add (fastJsonHttpMessageConverter );
64
50
return restTemplate ;
65
51
}
66
52
0 commit comments