代码:
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中:
原文地址:https://www.cnblogs.com/wangquanyi/p/11329022.html
时间: 2024-10-13 22:50:07