1、升级 Dockerfile
Dockerfile 中的JDK 镜像改为 JDK 17
#FROM aiban-docker.pkg.coding.net/tianyin/base/openjdk:8-jdk-alpine
#FROM aiban-docker.pkg.coding.net/tianyin/base/openjdk:8-jdk-alpine-skywalking
FROM aiban-docker.pkg.coding.net/tianyin/base/openjdk:17-jdk-alpine2、升级 Jenkinsfile
在 Jenkinsfile 文件的编译模块,增加 JDK 17 编译环境代理
agent {
docker {
reuseNode 'true'
registryUrl 'https://coding-public-docker.pkg.coding.net'
image 'public/docker/openjdk:17-2024.03'
}
}
3、升级 Maven 依赖
3.1、升级继承依赖
<parent>
<groupId>com.tianyin</groupId>
<artifactId>tianyin-cloud-parent</artifactId>
<version>2023.0.x.20250712-SNAPSHOT</version>
<relativePath/>
</parent>3.2、升级组件依赖
1、Knife4j 接口文档
<!-- For Knife4j -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>${springdoc.version}</version>
</dependency>2、Dozer 对象转换
<!-- For Dozer -->
<dependency>
<groupId>com.github.dozermapper</groupId>
<artifactId>dozer-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.github.hiwepy</groupId>
<artifactId>dozer-extra-converters</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
</dependency>3、Mybatis-Plus
<!-- For Mybatis-Plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-jsqlparser</artifactId>
</dependency>
<!-- For Mybatis Plus Generator -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
</dependency>3.3、升级程序版本
比如,业务中台,从 1.x.x 升级到了 3.0.0-SNAPSHOT
<version>3.0.0-SNAPSHOT</version>4、程序兼容改动
4.1、调整 application.yaml 默认配置
spring 配置发生了改变,去除了一些无效配置,修改了Redis 配置的格式
################################################################################################################
###Spring Boot 监控(安全、开放信息等)配置:
################################################################################################################
management:
server:
# 启用独立运维端口
port: 50000
metrics:
tags:
# 在统计信息中添加自定义的标签
application: ${spring.application.name}
# 开启shutdown和health端点
endpoint:
shutdown:
enabled: true
health:
enabled: true
probes:
enabled: true
endpoints:
web:
# 指定上下文路径,启用相应端点
base-path: /actuator
exposure:
include: health,shutdown,metrics,prometheus
############## SpringDoc 配置 (文档: https://springdoc.org/) ##############
springdoc:
api-docs:
enabled: true
path: /v3/api-docs
packages-to-scan:
- com.tianyin.dw.standard.web.mvc
swagger-ui:
path: /swagger-ui.html
tags-sorter: alpha
operations-sorter: alpha
knife4j:
enable: true
################################################################################################################
###Spring Boot 相关组件(SpringMVC、Freemarker、Session、Cache、DataSource)配置:
################################################################################################################
spring:
# 应用信息配置
application:
name: tianyin-edu-third
# 缓存配置:
cache:
type: none
# 配置文件导入:
config:
import:
- nacos:tianyin-common.yaml
- optional:nacos:${spring.application.name}.yaml
- optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml
# 数据源配置:
datasource:
name: ${spring.application.name}
# HiKariCP的数据源配置:
hikari:
enabled: true
allow-pool-suspension: true
auto-commit: false
# 连接初始化SQL
connection-init-sql: select SYSDATE()
# 连接测试语句
connection-test-query: select SYSDATE()
# 连接超时, 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQLException, 缺省:30秒
connection-timeout: 30000
initialization-fail-timeout: 30000
#一个连接idle状态的最大时长(毫秒),超时则被释放(retired),缺省:10分钟
idle-timeout: 600000
# 内存泄漏侦测入口
leak-detection-threshold: 30000
# 一个连接的最大的生命时间(毫秒),超时而且没被使用则被释放(retired),缺省:30分钟,建议设置比数据库超时时长少30秒以上,参考MySQL wait_timeout参数(show variables like '%timeout%';)
max-lifetime: 1800000
# 连接池中允许的最大连接数。缺省值:10;推荐的公式:((core_count * 2) + effective_spindle_count)
max-pool-size: 15
# 最小闲置线程
min-idle: 5
# 生效超时
validation-timeout: 30000
data:
# Redis相关配置
redis:
client-type: lettuce
# 连接超时时间(毫秒)
timeout: 50000
# 基于Lettuce客户端的Redis连接池配置
lettuce:
pool:
enabled: true
# 连接池最大连接数(使用负值表示没有限制)
max-active: 200
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1
# 连接池中的最大空闲连接
max-idle: 10
# 连接池中的最小空闲连接
min-idle: 0
# 国际化信息配置
messages:
#指定message的basename,多个以逗号分隔,如果不加包名的话,默认从classpath路径开始,默认: messages
basename: i18n/*/messages,i18n/messages
#设定Message bundles的编码,默认: UTF-8
encoding: UTF-8
# Servlet配置
servlet:
multipart:
enabled: true #默认支持文件上传
max-file-size: -1 #不做限制
max-request-size: -1 #不做限制
# 权限控制
security:
# 默认路径拦截规则定义
filter-chain-definition-map:
'[/]': anon
'[/favicon.ico]': anon
'[/webjars/**]': anon
'[/error*]': anon
'[/swagger-ui.html]': anon
'[/swagger-ui/**]': anon
'[/doc.html]': anon
'[/v2/*]': anon
'[/v2/api-docs]': anon
'[/v3/api-docs]': anon
'[/v3/api-docs/**]': anon
'[/actuator/**]': anon
'[/actuator*]': anon
# 以上是默认配置
'[/kaptcha*]': anon
'[/druid/*]': ipaddr[192.168.1.0/24]
'[/third/config/*]': anon
'[/image/*]': anon
'[/sms/*]': anon
'[/file/listByPath]': anon
'[/env/list]': anon
stateless: true
jwt:
enabled: true
authz:
enabled: true
allow-session-creation: false
continue-chain-before-successful-authentication: true
path-pattern: /*4.2、修改程序启动器
- 去除 @EnableExtrasConfiguration 注解
- 增加 @EnableDiscoveryClient 注解
- 替换 @EnableGlobalMethodSecurity 为 @EnableMethodSecurity
- 增加 @Import(DozerAutoConfiguration.class) 解决 Dozer 框架不兼容 Spring Boot 3 问题
@EnableCaching(proxyTargetClass = true)
@EnableDiscoveryClient
@EnableFeignClients(basePackages = "com.tianyin.edu.**.feign")
@EnableWebSecurity
@EnableMethodSecurity(prePostEnabled = true)
@SpringBootApplication
@Import(DozerAutoConfiguration.class)4.3、feign 框架变更的兼容修改
feign.hystrix.FallbackFactory >> org.springframework.cloud.openfeign.FallbackFactory4.3、Java 标准变更的兼容修改
使用批量替换下面的变更:
javax.servlet >> jakarta.servlet
javax.validation >> jakarta.validation
javax.annotation >> jakarta.annotation4.4、Mybatis-Plus 注解调整
把 @TableField(updateStrategy = FieldStrategy.IGNORED ) 改为 @TableField(updateStrategy = FieldStrategy.NEVER )
作者:杭州天音 创建时间:2025-07-16 13:45
最后编辑:杭州天音 更新时间:2025-08-11 13:50
最后编辑:杭州天音 更新时间:2025-08-11 13:50