jdk由1.8升级到17
spring-boot由2.7.6升级到3.1.2版本
spring-cloud-alibaba由2021.0.4.0升级到2022.0.0.0-RC2版本
maven构建插件里的配置要改为17:
org.apache.maven.plugins maven-compiler-plugin3.11.0 17 UTF-8
javax相关的包要改为jakarta:
javax.servlet javax.servlet-apijakarta.servlet jakarta.servlet-api
Spring Boot3.0已经将依赖项从Java EE迁移到Jakarta EE API(主要是避免Oracle 的版权问题),所以要将项目中的 javax.servlet.* 改为 jakarta.servlet.*
IDEA工具提供了迁移工具,可以较为方便的修改Jakarta
IDEA官方文档:Migrate | IntelliJ IDEA Documentation
log4j需要升级到2.19.0及以上版本:
org.apache.logging.log4j log4j-core2.19.0 org.apache.logging.log4j ......2.19.0
1、org.springframework.web.filter.HttpPutFormContentFilter已经被废弃并移除了,可以使用org.springframework.web.filter.FormContentFilter来替代。
FormContentFilter类能够解析PUT和PATCH请求中的表单数据并将其作为请求参数传递给控制器方法。
// 如果之前过滤器配置了HttpPutFormContentFilter @Bean public FilterRegistrationBeanHttpPutFormContentFilter() { FilterRegistrationBean registrationBean = new FilterRegistrationBean (); registrationBean.setFilter(new HttpPutFormContentFilter()); registrationBean.addUrlPatterns("/*"); registrationBean.setOrder(2); return registrationBean; } // 改成FormContentFilter // FormContentFilter类能够解析PUT和PATCH请求中的表单数据并将其作为请求参数传递给控制器方法 @Bean public FilterRegistrationBean FormContentFilter() { FilterRegistrationBean registrationBean = new FilterRegistrationBean (); registrationBean.setFilter(new FormContentFilter()); registrationBean.addUrlPatterns("/*"); registrationBean.setOrder(2); return registrationBean; }
2、org.springframework.web.servlet.handler.HandlerInterceptorAdapter已经被废弃并移除了,可以使用org.springframework.web.servlet.handler.HandlerInterceptor接口来替代。
@Component public class CustomInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { HandlerInterceptor.super.preHandle(request, response, handler); return true; } @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { HandlerInterceptor.super.postHandle(request, response, handler, modelAndView); } @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { HandlerInterceptor.super.afterCompletion(request, response, handler, ex); } }
3、编译错误:
无法将类 org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping中的构造器 WebMvcEndpointHandlerMapping应用到给定类型;
WebMvcEndpointHandlerMapping构造方法是6个参数,检查一下,不要少传或多传了。
4、编译错误:
对于ServletRegistrationBean(com.alibaba.druid.support.http.StatViewServlet,java.lang.String), 找不到合适的构造器
druid版本升级到1.2.18,com.alibaba.druid.support.http.StatViewServlet 改为 com.alibaba.druid.support.jakarta.StatViewServlet
com.alibaba druid1.2.18
5、编译错误:
不兼容的类型: com.alibaba.druid.support.http.WebStatFilter无法转换为jakarta.servlet.Filter
同上,druid版本升级到1.2.18,com.alibaba.druid.support.http.WebStatFilter 改为 com.alibaba.druid.support.jakarta.WebStatFilter
6、mybatis版本问题:
java.lang.NoClassDefFoundError: org/springframework/core/NestedIOException
需要升级mybatis的版本 ,对应版本如下: