赞
踩
项目由于安全漏洞扫描,需要将spring-web版本升级到6.0及以上,由于springboot2只支持spring-web5,故需要进行升级
升级过程中遇到问题及解决方案如下
升级到jdk17
改成 implements WebMvcConfigurer
javax基本上都要改为jakarta
改为httpstatuscode
改为 .authorizeHttpRequests(auth -> auth
.requestMatchers("/token/**").permitAll()
.anyRequest().authenticated()
)
添加spring-remoting 依赖
参考 tcnative-1.dll: Can't load IA 32-bit-CSDN博客
启动类需要使用@SpringBootApplication注解,不能只使用@EnableAutoConfiguration,否则不加载静态文件
开始是将mybatis-plus升级到3.5.5 ,但是 3.5.5 有bug 启动报错 回退到3.5.3.1
且mybatis-spring 需要升级到3.0.3
调整代码,去掉代码中的循环引用
druid版本不匹配 mssql-jdbc 升级到 9.5.0.jre17-preview
druid改成 <artifactId>druid-spring-boot-3-starter</artifactId>
原本的tomcat9,启动到org.apache.catalina.startup.Catalina.start后不动也不报错 下载了一个新版本也是一样,会去解压war包但是不会加载war
tomcat10 dbType识别不了,启动报错
create connection RuntimeException
java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because "this.dbTypeName" is null
@ConfigurationProperties 在springboot3 中不能直接在方法上赋值
tomcat11 启动闪退 好像是最低jdk要求是21
总结,只能使用tomcat10,且数据源配置加载类要重新写,不然无法正常启动
修改server.xml配置
<Connector
protocol="org.apache.coyote.http11.Http11NioProtocol"
port="443"
maxThreads="150"
SSLEnabled="true">
<SSLHostConfig>
<Certificate
certificateKeystoreFile="c:/cert/xxxxx.keystore"
certificateKeystorePassword="xxxxxx"
type="RSA"
/>
</SSLHostConfig>
</Connector>
产生原因是请求地址最后多了一个/ 去掉不带参数的请求的最后一个多余/
数据库超时时间默认只有10s,修改连接数据源代码,增加dataSource.setSocketTimeout 配置
使用新的方式去写,参考 SpringBoot 3.x 集成OAuth 2.0实现认证授权服务及资源服务 - 知乎
以上就是升级springboot过程中遇到的一些问题及解决方案,如有更好的方案欢迎交流。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。