SpringBoot 2.18升级到2.7.5, 踩到的坑

系统要求:

jdk 8~19


1,mybatis 实体注解失败,

相应maven添加

<dependency>
 <groupId>javax.validation</groupId> 
<artifactId>validation-api</artifactId> 
<version>2.0.1.Final</version> 
<scope>compile</scope> 
</dependency>

mybatis-spring-boot-starter 升级到2.2.2

com.github.pagehelper 升级 1.4.4

org.apache.shiro 升级 1.10.0

2,MultipartProperties 中 文件大小 的后缀,只识别大写

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181)

at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)

at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)

at java.base/java.lang.Iterable.forEach(Iterable.java:75)

3,swagger 升级

<dependency> 
<groupId>io.springfox</groupId> 
<artifactId>springfox-swagger2</artifactId> 
<version>3.0.0</version> 
<scope>compile</scope> 
</dependency> 

<dependency> 
<groupId>io.springfox</groupId> 
<artifactId>springfox-swagger-ui</artifactId> 
<version>3.0.0</version> 
<scope>compile</scope> 
</dependency>

Springfox使用的路径匹配是基于AntPathMatcher的,而Spring Boot 2.6.X使用的是PathPatternMatcher,增加mvc配置,

spring:
    mvc:
      pathmatch:
        matching-strategy: ant_path_matcher

访问:http:/127.0.0.1/swagger-ui/index.html

注:swagger2的访问地址:是http:/127.0.0.1/swagger-ui.html

4,升级 shardingsphere

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
    <version>4.1.1</version>
</dependency>

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>sharding-jdbc-spring-namespace</artifactId>
    <version>4.1.1</version>
</dependency>

5,spring.rabbitmq.publisher-confirms Deprecated

替换成:spring.rabbitmq.publisher-confirm-type=correlated

6,yml配置文件更改

Property 'spring.profiles.include[0]' imported from location 'class path resource [application-prod.yml]' is invalid in a profile specific resource [origin: class path resource [application-prod.yml] -

include不能单独使用 

spring:
  config:
    import: application-common-prod.yml

7,升级 elasticsearch

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>

报错:

Factory method 'esClient' threw exception; nested exception is java.lang.NoClassDefFoundError: jakarta/json/spi/JsonProvider

解决方案:

父模块添加声明依赖

<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<version>2.0.1</version>
</dependency>

8,升级后 ,屏蔽 自带的tomcat , 使用 undertow

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <!-- Exclude the Tomcat dependency -->
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-undertow</artifactId>
</dependency>

 9,升级后 监听器使用@ConfigurationProperties(prefix="website"),报空指针

没找到具体原因,

猜测可能是加载顺序的问题,监听器在springboot容器外,可能是监听器加载时,springboot没有加载完,导致空指针异常。

后来直接在监听器中使用@Value注入资源文件属性,打印俩次日志,第一次时空数据,第二次数据加载,可能还是容器外管理的问题,加载顺序不一致导致的。

暂时得到解决,后面再找具体原因,如果有知道的也可以评论栏给下提示,万分感谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fjza1168

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值