springboot艰难版本升级之路!! springboot 2.3.x版本升级到2.7.x版本

本文记录了从SpringBoot 2.3.x升级到2.7.12过程中遇到的挑战,包括启动失败、配置加载、openfeign依赖、datasource报错、MySQL驱动升级、循环依赖、跨域错误、swagger集成、DataSource问题和RedisClient版本问题。通过调整springcloud版本、配置项、升级相关依赖等解决了一系列问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.缘起

由于服务需要搭建链路追踪, 需要把springboot版本升级到2.7.12. 目前服务是2.3.x.
springboot版本 有几个版本改动是比较大的. 2.4.x/3.0.x 这两个版本具有一定的跨度.
由于我们服务使用springboot的版本太低了. 因此注定升级之路就是不平坦的

下面将我遇到的问题以及解决方案, 一一贴在下面

1.1 升级到版本2.7.12启动失败,而且没有报错信息

步骤:

开始是直接把springboot的版本改到了2.7.12

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.12</version>
        <relativePath/> <!-- lookup parent from repository -->
</parent>

现象:

无任何有用的报错信息
启动没有任何提示信息,但启动不了.

解决方案:

进过断点调试,发现是springcloud 版本对应有问题,将springcloud的版本改为:
<spring-cloud.version>2021.0.3</spring-cloud.version>
并且将 spring-cloud-alibaba.version 的版本改为
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>

1.2 application-dev.yml 配置加载问题

现象:

在这里插入图片描述
解决方案:

在配置中添加 spring.config.use-legacy-processing: true . 为了兼容老的加载配置文件

1.3 openfeign依赖问题汇总

现象1:

启动接着报错.

Caused by: java.io.FileNotFoundException: class path resource [feign/hystrix/FallbackFactory.class] cannot be opened because it does not exist
在这里插入图片描述

现象2:

Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class] cannot be opened because it does not exist
在这里插入图片描述

解决方案:

升级 openfeign, 以及ribbon版本

		<openfeign.version>3.1.3</openfeign.version>
		<ribbon.version>2.2.10.RELEASE</ribbon.version>

		<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
            <version>${ribbon.version}</version>
        </dependency>

		<!--接口调用-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
            <version>${openfeign.version}</version>
        </dependency>

1.4 datasource报错

现象:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘webMvcMetricsFilter’ defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method ‘webMvcMetricsFilter’ parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘prometheusMeterRegistry’ defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource’ defined in class path resource [com/baomidou/dynamic/datasource/spring/boot/autoconfigure/DynamicDataSourceAutoConfiguration.class]: Invocation of init method failed; nested exception is com.baomidou.dynamic.datasource.exception.ErrorCreateDataSourceException: druid create error
在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

漫长的~以后

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

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

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

打赏作者

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

抵扣说明:

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

余额充值