坑爹的发版流水线,管天管地,springboot2过了维护期,就催着我们升级。
导致必须上jdk17
记录一下升级需要处理的事情
- 先升级springboot和cloud,这里定下基调,其他的才好跟着升级
https://spring.io/projects/spring-boot#learn 看ga版本
https://spring.io/projects/spring-cloud#learn 这是cloud的,
干脆来个狠的,springcloud升到当前最新
https://docs.spring.io/spring-cloud-release/reference/index.html 有对应的springboot版本
Release Train Version: 2023.0.2
Supported Boot Version: 3.2.6
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>3.2.6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2023.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
springboot的一些要求:
https://docs.spring.io/spring-boot/docs/3.2.6/reference/html/getting-started.html#getting-started
Build Tool | version |
---|---|
Maven | 3.6.3 or later |
Gradle | 7.x (7.5 or later) and 8.x |
容器要求
Servlet Containers
Spring Boot supports the following embedded servlet containers:
Name | Servlet Version |
---|---|
Tomcat 10.1 | 6.0 |
Jetty 12.0 | 6.0 |
Undertow 2.3 | 6.0 |
- mybitis-plus 要升级,注意配置可能要调整,分页和@version乐观锁可能需要调整,
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
</dependency>
- mysql的jdbc换了
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
- 连接池
<!-- https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-3-starter -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-3-starter</artifactId>
<version>1.2.20</version>
</dependency>
- redis配置变化了,多了一个层级data
##### redis配置
spring.data.redis.host=192.168.50.101
spring.data.redis.port=6379
spring.data.redis.database=11
spring.data.redis.password=haoxun
spring.data.redis.timeout=5000
spring.data.redis.lettuce.pool.enabled= true
# 连接池最大连接数(使用负值表示没有限制)
spring.data.redis.lettuce.pool.max-active=5
# 连接池中的最大空闲连接
spring.data.redis.lettuce.pool.max-idle=5
# 连接池中的最小空闲连接
spring.data.redis.lettuce.pool.min-idle=1
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.data.redis.lettuce.pool.max-wait=5000
spring.data.redis.lettuce.pool.time-between-eviction-runs=1000
- servlet-api 升级
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
变成了
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
-
Java11的javax.调整为Jakarta.
有不少javax的import ,需要换包路径,变成了jakarta
javax.validation替换为jakarta.validation
javax.servlet替换为jakarta.servlet -
SpringBoot2.6.X默认就关闭了允许循环依赖,
所以若是2.6.X以下的SpringBoot版本升级,需要增加如下配置,允许开启循环依赖。
spring.main.all-circular-references: true
-
Hystrix和Ribbon已过时
由于Hystrix和Ribbon已停止升级,Hystrix被circuit-breaker(resilience4j或sentinel)取代,
Ribbon被load-balancer取代。maven类库引用变为: -
内置声明式HTTP客户端
-
swagger3需要改变
-
Java9的模块化特性
-
lombok 需要更着升