RestTemplateConfig写法,用于配置Template引擎模板


代码:

 1 import org.springframework.context.annotation.Bean;
 2 import org.springframework.context.annotation.Configuration;
 3 import org.springframework.http.client.ClientHttpRequestFactory;
 4 import org.springframework.http.client.SimpleClientHttpRequestFactory;
 5 import org.springframework.web.client.RestTemplate;
 6 @Configuration
 7 public class RestTemplateConfig {
 8     @Bean
 9     public RestTemplate restTemplate(ClientHttpRequestFactory factory){
10         return new RestTemplate(factory);
11     }
12     @Bean
13     public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
14         SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
15         factory.setReadTimeout(5000);
16         factory.setConnectTimeout(5000);
17         return factory;
18     }
19 }

yml配置:

1 #禁用模板引擎的缓存
2 thymeleaf:
3   cache: false
4 resources:
5   static-locations: classpath:/static/
6 mvc:
7   data-format: yyyy-mm-dd HH:mm:ss

把html放在templates中:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM