我用的springboot+jpa+thymeleaf
1. BaseRepositoryFactory的getTargetRepository变了
原来的
@Override
protected Object getTargetRepository(RepositoryInformation information) {
return new BaseJpaRepository((Class)information.getDomainType(), em);
}
改为:
@Override
protected JpaRepositoryImplementation, ?> getTargetRepository(RepositoryInformation information,EntityManager entityManager) {
JpaEntityInformation, Serializable> entityInformation = this.getEntityInformation(information.getDomainType());
Object repository = this.getTargetRepositoryViaReflection(information, new Object[]{entityInformation, entityManager});
Assert.isInstanceOf(BaseJpaRepository.class, repository);
return (JpaRepositoryImplementation)repository;
}
2. 查询的排序变了
Sort sort = new Sort(Direction.ASC, "字段");
改为:
Sort sort = Sort.by(Sort.Direction.ASC, "字段");
3. thymeleaf的引用模板页不起作用了。所有页面都乱了。
引用模板的部分layout:decorator改成使用新的标签 layout:decorate 进行页面布局。
4. 由于thymeleaf升级,页面会报一个错误
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Only variable expressions returning numbers or booleans are allowed in this context, any other datatypes are not trusted in the context of this expression, including Strings or any other object that could be rendered as a text literal. A typical case is HTML attributes for event handlers (e.g. "onload"), in which textual data from variables should better be output to "data-*" attributes and then read from the event handler. (template: "itilView/other/createFlow2" - line 913, col 168)
th:onclick="turn_other_process+${item_btn.key}"
改为
th:onclick="turn_other_process[[${item_btn.key}]]"
4. 文件上传大小设置
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
//单个文件最大
factory.setMaxFileSize("10240MB"); //KB,MB
/// 设置总上传数据总大小
factory.setMaxRequestSize("102400MB");
return factory.createMultipartConfig();
}
改为在application里面直接设置
spring.http.multipart.maxFileSize: 10240MB
spring.http.multipart.maxRequestSize: 102400MB
5. 修改restTemplate的超时时间:
@Autowired
private RestTemplateBuilder builder;
// 使用RestTemplateBuilder来实例化RestTemplate对象,spring默认已经注入了RestTemplateBuilder实例
@Bean
public RestTemplate restTemplate() {
return builder.setConnectTimeout(2000).setReadTimeout(2000).build();
}
改为:
@Bean
public RestTemplate restTemplate() {
HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
httpRequestFactory.setConnectionRequestTimeout(60*1000);
httpRequestFactory.setConnectTimeout(60*1000);
httpRequestFactory.setReadTimeout(60*1000);
return new RestTemplate(httpRequestFactory);
}
6. 升级后,restTemplate 的url格式要求严格了。本来项目是spring cloud的结构,多个微服务。升级后,有些地方URL存在//,就不能访问了。需要调整。
例如:
http://127.0.0.1/微服务名称/方法名
以前为了安全起见,可能存在
http://127.0.0.1/微服务名称//方法名
的情况
微服务名称后面自带的"/"全部去掉