SpringBoot 2.2.5
升级到 2.7.7
SpringCloudHoxton.SR10
升级到2021.0.5
SpringCloudAlibaba2.2.1.RELEASE
升级到2021.0.4.0
-
如果项目中使用了
@NotNull
、@NotBlank
等注解时,可能会报错java: 程序包javax.validation.constraints不存在
2.2.5
在spring-boot-starter
中引入的该依赖,在高版本中(具体哪个版本未知)中将其排除了
引入jakarta.validation-api
依赖即可解决<!-- spring-boot-dependencies 管理了改以来版本,正常不需要指定版本 --> <dependency> <groupId>jakarta.validation</groupId> <artifactId>jakarta.validation-api</artifactId> </dependency>
-
加载不到
BootStrap.yml
文件
在升级到2.4
版本后,加载方式发生改- 添加依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> </dependency>
-
Feign
接口的FallbackFactory
类包发生改变
由原先的feign.hystrix.FallbackFactory
改为org.springframework.cloud.openfeign.FallbackFactory
-
The bean ‘xxx.FeignClientSpecification’ could not be registered. A bean with that name has already been defined and overriding is disabled.
查看依赖包中是否有@EnableFeignClients
注解,如果一个项目中有多个该注解会报错 -
nacos
注册失败ERROR | com.alibaba.nacos.client.Worker | com.alibaba.nacos.common.remote.client | Send request fail, request …
确保部署了对应版本的
Nacos
服务端,我部署的版本为nacos-2.2.0
Nacos
配置文件结构发生变化
修改前:
修改后:
-
The dependencies of some of the beans in the application context form a cycle
A类引用了B类,B类引用了A类。
在
Spring 2.6
之前会自动类解决循环依赖问题,升级之后只能手动解决- 去除循环依赖的逻辑
- 配置文件配置
Spring.main.allow-circular-references=true
- 主启动类
public static void main(String[] args) { SpringApplication s = new SpringApplication(xx.class); s.setAllowCircularReferences(Boolean.TRUE);//加入的参数 s.run(args); }
``
-
No application config found or it’s not a valid config! Please add <dubbo:application name=“…” /> to your spring config.
Dubbo2
会和JDK版本有冲突导致该问题,Dubbo3
针对该问题进行了重构
Dubbo2
和Dubbo3
版本配置文件不兼容会导致该问题,需要根据官网配置项进行配置 -
Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
SpringBoot2.6
之后将SpringMVC
默认路径匹配策略从AntPathMatcher
更改为PathPatternParser
,导致出错
添加配置spring: mvc: pathmatch: matching-strategy: ant_path_matcher
-
When allowCredentials is true, allowedOrigins cannot contain the special value “*” since that cannot be set on the “Access-Control-Allow-Origin” response header. To allow credentials to a set of origins, list them explicitly or consider using “allowedOriginPatterns” instead.
Springboot
升级到2.4
之后AllowedOrigin
不能有'*
,可以用addAllowedOriginPattern
代替。如果是
gateway
报错可以修改配置文件:spring: cloud: gateway: default-filters: - DedupeResponseHeader=Access-Control-Allow-Origin, RETAIN_UNIQUE globalcors: cors-configurations: '[/**]': # 允许携带认证信息 allowCredentials: true # 允许跨域的源(网站域名/ip),设置*为全部1 # allowedOrigins: "*" allowedOriginPatterns: "*" # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部 allowedMethods: "*" # 允许跨域请求里的head字段,设置*为全部 allowedHeaders: "*"
-
Gateway报错Unable to find instance for xxx
高版本移除了Ribbon
,需要手动添加·spring-cloud-starter-loadblancer`依赖<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-loadbalancer</artifactId> </dependency>