SpringBoot2.2.5升级到2.7.7 SpringCloudHoxton.SR10升级到2021.0.5 SpringCloudAlibaba2.2.1.RELEASE升级到2021.0.4

SpringBoot 2.2.5 升级到 2.7.7
SpringCloudHoxton.SR10升级到2021.0.5
SpringCloudAlibaba2.2.1.RELEASE升级到2021.0.4.0

  1. 如果项目中使用了@NotNull@NotBlank等注解时,可能会报错java: 程序包javax.validation.constraints不存在
    2.2.5spring-boot-starter中引入的该依赖,在高版本中(具体哪个版本未知)中将其排除了
    引入jakarta.validation-api依赖即可解决

    <!-- spring-boot-dependencies 管理了改以来版本,正常不需要指定版本 -->
         <dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
        </dependency>
    
  2. 加载不到BootStrap.yml文件
    在升级到 2.4版本后,加载方式发生改

    • 添加依赖
        <dependency>
           <groupId>org.springframework.cloud</groupId>
           <artifactId>spring-cloud-starter-bootstrap</artifactId>
       </dependency>
    
  3. Feign接口的FallbackFactory类包发生改变
    由原先的feign.hystrix.FallbackFactory改为org.springframework.cloud.openfeign.FallbackFactory

  4. The bean ‘xxx.FeignClientSpecification’ could not be registered. A bean with that name has already been defined and overriding is disabled.
    查看依赖包中是否有@EnableFeignClients注解,如果一个项目中有多个该注解会报错

  5. nacos注册失败

    ERROR | com.alibaba.nacos.client.Worker | com.alibaba.nacos.common.remote.client | Send request fail, request …

    确保部署了对应版本的Nacos服务端,我部署的版本为nacos-2.2.0
    Nacos 配置文件结构发生变化
    修改前:
    在这里插入图片描述
    修改后:
    在这里插入图片描述

  6. 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);
    }
    

``

  1. No application config found or it’s not a valid config! Please add <dubbo:application name=“…” /> to your spring config.
    Dubbo2会和JDK版本有冲突导致该问题,Dubbo3针对该问题进行了重构
    Dubbo2Dubbo3版本配置文件不兼容会导致该问题,需要根据官网配置项进行配置

  2. Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
    SpringBoot2.6之后将SpringMVC 默认路径匹配策略从AntPathMatcher 更改为PathPatternParser,导致出错
    添加配置

    spring:
      mvc:
        pathmatch:
          matching-strategy: ant_path_matcher
    
  3. 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: "*"
    
  4. 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>
    
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值