SpringCloudAlibaba升级手册

目录

1. 版本对照

版本现状

SpringCloud与AlibabaCloud对应版本

Springboot与Elasticsearch版本对应

2. openfeign问题

问题

解决方案

3. Feign请求问题

问题

解决方法

4. Sentinel循环依赖

问题

解决方案

5. bootstrap配置文件不生效

问题

解决方案

6. Nacos的连接错误

问题

解决方案

7. 跨域问题

问题

解决方案


1. 版本对照

版本现状

组件

版本

新版本

SpringBoot

2.3.2.RELEASE

2.7.18

SpringCloud

Hoxton.SR9

2021.0.9

SpringCloudAlibaba

2.2.6.RELEASE

2021.0.5.0

spring-boot-starter-data-elasticsearch

2.3.2.RELEASE

SpringBoot版本内部定义

nacos-client

1.4.2

AlibabaCloud版本内部定义(2.2.0)

SpringCloud与AlibabaCloud对应版本

信息来源:

版本发布说明-阿里云Spring Cloud Alibaba官网

Springboot与Elasticsearch版本对应

Spring Boot 和 Elasticsearch 的版本兼容关系需要根据 Spring Data Elasticsearch 模块的版本来确定,因为 Spring Boot 通过 Spring Data Elasticsearch 来集成 Elasticsearch。以下是一些常见的版本对应关系

Spring Boot 版本

Spring Data Elasticsearch 版本

Elasticsearch 版本

3.1.x

5.1.x

8.x

3.0.x

5.0.x

8.x

2.7.x

4.4.x

7.x

2.6.x

4.3.x

7.x

2.5.x

4.2.x

7.x

2.4.x

4.1.x

7.x

2.3.x

4.0.x

7.x

2.2.x

3.2.x

6.x

2.1.x

3.1.x

6.x

2.0.x

3.0.x

5.x

    RestHighLevelClient:从 Spring Data Elasticsearch 4.x 开始,推荐使用 Elasticsearch 官方的 RestHighLevelClient 代替旧的 TransportClient。

    Elasticsearch 7.x 引入了一些重要的映射变化,比如默认情况下不再需要指定 _type 字段,所有文档类型默认使用 _doc。

2. openfeign问题

问题

Unexpected exception during bean creation; nested exception is java.lang.IllegalArgumentException: @RequestMapping annotation not allowed on @FeignClient interfaces

Spring Cloud OpenFeign 3.x 版本中 @FeignClient 接口上不允许使用 @RequestMapping 注解的限制。

解决方案

将老代码中的 @RequestMapping 替换为具体的请求方式注解,例如 @GetMapping、@PostMapping 等。

修改前:

@FeignClient(name = "example-service")@RequestMapping("/example")public interface ExampleFeignClient {@RequestMapping(method = RequestMethod.GET, value = "/getData")String getData();}

 

修改后:

@FeignClient(name = "example-service")public interface ExampleFeignClient {@GetMapping("/example/getData")String getData();}

Content-Type 头部设置了一个不允许的通配符 '*',而 Feign 不支持这种情况。

注解中加上 consumes = "application/json"参数,明确规定了请求的 Content-Type。

3. Feign请求问题

问题

Unexpected exception during bean creation; nested exception is java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?

解决方法

你可以通过在 pom.xml 文件中手动添加 spring-cloud-starter-loadbalancer 依赖来解决这个问题:

<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId></dependency>

4. Sentinel循环依赖

问题

Description:

The dependencies of some of the beans in the application context form a cycle:

   xxxxxImpl

      ↓

   XxxxxImpl

      ↓

   org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration

┌─────┐

|  com.alibaba.cloud.sentinel.SentinelWebAutoConfiguration (field private java.util.Optional com.alibaba.cloud.sentinel.SentinelWebAutoConfiguration.sentinelWebInterceptorOptional)

└─────┘

Action:

Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.

解决方案

升级为当前 Spring Cloud 一样的版本。

<!--sentinel版本-->
<spring-cloud-starter-alibaba-sentinel.version>2021.0.5.0</spring-cloud-starter-alibaba-sentinel.version>

参考资料:

https://github.com/alibaba/spring-cloud-alibaba/issues/2322
https://juejin.cn/post/7080801716483915783  alibaba-sentinel启动报循环依赖
https://developer.aliyun.com/article/861163  springboot升级到2.6.1的坑
https://cloud.tencent.com/developer/article/2186649  我服了!SpringBoot升级后这服务我一个星期都没跑起来!

5. bootstrap配置文件不生效

问题

org.springframework.cloud.commons.ConfigDataMissingEnvironmentPostProcessor$ImportException: No spring.config.import set

Description:

No spring.config.import property has been defined

Action:

Add a spring.config.import=nacos: property to your configuration.

If configuration is not required add spring.config.import=optional:nacos: instead.

To disable this check, set spring.cloud.nacos.config.import-check.enabled=false.

解决方案

<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>

参考资料:

https://cloud.tencent.com/developer/ask/sof/108770896
https://sca.aliyun.com/en/faq/sca-user-question-history13954/

6. Nacos的连接错误

问题

ErrCode:-401, ErrMsg:Client not connected,current status:STARTING的解决方案

解决方案

开通相应新增端口

参考资料:

https://www.cnblogs.com/linyb-geek/p/16601335.html
https://nacos.io/zh-cn/docs/v2/upgrading/2.0.0-compatibility.html
https://blog.csdn.net/fenglibing/article/details/120164149

7. 跨域问题

问题

java.lang.IllegalArgumentException: 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.0之后,跨域配置中的.allowedOrigins不再可用,将配置中的.allowedOrigins替换成.allowedOriginPatterns即可

参考资料:

https://blog.csdn.net/weixin_43901865/article/details/119737447

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/55281.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Codeforces Round 929 (Div. 3) F. Turtle Mission: Robot and the Earthquake

题目 题解&#xff1a; 按题解思路的代码&#xff1a; #include <bits/stdc.h>using i64 long long;void solve() {int n, m;std::cin >> n >> m;std::vector a(n, std::vector<int>(m));for (int i 0; i < n; i) {for (int j 0; j < m; j) …

STM32—SPI通讯协议

前言 由于I2C开漏外加上拉电阻的电路结构&#xff0c;使得通信线高电平的驱动能力比较弱&#xff0c;这就会号致&#xff0c;通信线由候电平变到高电平的时候&#xff0c;这个上升沿耗时比较长&#xff0c;这会限制I2C的最大通信速度&#xff0c; 所以&#xff0c;I2C的标准模…

uniapp-小程序开发0-1笔记大全

uniapp官网&#xff1a; https://uniapp.dcloud.net.cn/tutorial/syntax-js.html uniapp插件市场&#xff1a; https://ext.dcloud.net.cn/ uviewui类库&#xff1a; https://www.uviewui.com/ 柱状、扇形、仪表盘库&#xff1a; https://www.ucharts.cn/v2/#/ CSS样式&…

经纬恒润荣获2024中国汽车供应链大会创新成果奖

2024年9月24日-26日&#xff0c;2024中国汽车供应链大会暨第三届中国新能源智能网联汽车生态大会在武汉隆重举办。本届大会以“新挑战、新对策、新机遇——推动中国汽车供应链可持续发展”为主题&#xff0c;集聚政府主管领导、行业专家、汽车及零部件企业精英和主流媒体&#…

Ubuntu24.04 安装 NCAR Command Language(NCL)

目录 一般直接在Terminal中使用apt安装命令即可&#xff0c; 出现这样的问题&#xff0c; 如何解决这个问题呢&#xff1f; 一般直接在Terminal中使用apt安装命令即可&#xff0c; sudo apt install ncl-ncarg 但是&#xff0c;由于 Ubuntu 版本较新 Ubuntu 24.04&#xff…

Application protocol

### 11 应用协议 #### 11.1 通用程序 - 涉及不同类型文件的程序应遵循3GPP TS 31.101 [55]的规定&#xff0c;但不支持使用短文件ID。 #### 11.2 SIM管理程序 - 包括SIM初始化、GSM会话终止、紧急呼叫代码请求、语言偏好请求、行政信息请求、SIM阶段请求等。 - SIM初始化包括…

Python OpenCV精讲系列 - 三维重建深入理解(十七)

&#x1f496;&#x1f496;⚡️⚡️专栏&#xff1a;Python OpenCV精讲⚡️⚡️&#x1f496;&#x1f496; 本专栏聚焦于Python结合OpenCV库进行计算机视觉开发的专业教程。通过系统化的课程设计&#xff0c;从基础概念入手&#xff0c;逐步深入到图像处理、特征检测、物体识…

迪杰斯特拉算法的理解

图片转载自&#xff1a;最短路径算法-迪杰斯特拉(Dijkstra)算法 - 程序小哥爱读书的文章 - 知乎 https://zhuanlan.zhihu.com/p/346558578 迪杰斯特拉&#xff0c;一个广度优先算法&#xff0c;采用了贪心策略。 第一步&#xff0c;选取顶点D&#xff0c;更新和D相连的节点C&a…

78天闭门深造1258页SpringCloud学习进阶笔记,再战蚂蚁金服

概述 作为一名程序员应该都知道SpringCloud&#xff0c;不知道就该反思一下了啊[奸笑]。所以就不有板有眼的和官方的介绍一样了&#xff0c;今天就说一下&#xff0c;我理解的SpringCloud是什么&#xff1a;我所理解的Spring Cloud就是微服务系统架构的一站式解决方案&#xf…

Java项目: 基于SpringBoot+mysql+maven+vue林业产品推荐系统(含源码+数据库+毕业论文)

一、项目简介 本项目是一套基于SpringBootmybatismavenvue林业产品推荐系统 包含&#xff1a;项目源码、数据库脚本等&#xff0c;该项目附带全部源码可作为毕设使用。 项目都经过严格调试&#xff0c;eclipse或者idea 确保可以运行&#xff01; 该系统功能完善、界面美观、操…

Python-计算三角形面积的方法

&#xff03;Python创建用于计算的属性 &#xff03;定义一个三角形类&#xff0c;在__init__&#xff08;&#xff09;方法中定义实例属性. &#xff03;定义一个计算三角形面积的方法&#xff0c;并应用&#xff20;property将其转换为属性&#xff0c;最后创建类的实例&am…

算法工程师重生之第二十七天(合并区间 单调递增的数字 监控二叉树 总结)

参考文献 代码随想录 一、合并区间 以数组 intervals 表示若干个区间的集合&#xff0c;其中单个区间为 intervals[i] [starti, endi] 。请你合并所有重叠的区间&#xff0c;并返回 一个不重叠的区间数组&#xff0c;该数组需恰好覆盖输入中的所有区间 。 示例 1&#xff1a…

数据压缩(4)——字典编码

【前言】 变长编码&#xff0c;统计压缩编码都是基于单个字符的编码&#xff0c;字典编码基于数个连续字符&#xff08;也叫基于单词&#xff09;&#xff0c;例如ABCABD中AB可以替换成一个新的字符&#xff0c;其可能会减少字符数量&#xff0c;得到的新数据的熵比原来的小&a…

【推导过程】常用连续分布的数学期望、方差、特征函数

文章目录 相关教程相关文献常用连续分布的数学期望&方差&特征函数正态分布标准正态分布一般正态分布的标准化数学期望方差 3 σ 3\sigma 3σ原则 均匀分布数学期望方差 指数分布无记忆性数学期望方差 伽马分布两个特例数学期望方差 贝塔分布数学期望方差 作者&#xff…

Windows git 配置

需要在git-bash的目录下,配置.ssh 的配置文件 要 .ssh 目录下的配置无法使用

【SPIE独立出版】第四届计算机、信息工程与电子材料国际学术会议 (CTIEEM 2024,2024年11月15-17日 )

第四届计算机、信息工程与电子材料国际学术会议 (CTIEEM 2024) The 4th International Conference on Computer Technology, Information Engineering and Electron Materials 会议官网&#xff1a;www.ctieem.org The 4th International Conference on Computer Technology,…

python中的global和nonlocal关键字以及闭包和模块

global i 这样的用法在于 Python 中&#xff0c;但需要在一个函数内部使用&#xff0c;以便将变量 i 声明为全局变量。让我们来详细讲解一下它的用法。 什么是全局变量&#xff1f; 全局变量是指在函数外部定义的变量&#xff0c;可以在任何函数中访问和修改。如果你需要在函数…

C#无标题栏窗体拖动

要实现C#无标题栏窗体的拖动功能&#xff0c;可以使用以下步骤&#xff1a; 在窗体的构造函数中添加以下代码&#xff0c;将窗体的边框样式设置为无标题栏和可调整大小的窗体&#xff1a; this.FormBorderStyle FormBorderStyle.Sizable; this.Text String.Empty;添加以下代…

【解决】nvidia nx板运行python程序出现Segmentation fault (core dumped)问题

问题&#xff1a;运行python程序出现Segmentation fault (core dumped)问题。 bdlfbdlf-desktop:~/2、car_detect$ python3 test_zxh.py Segmentation fault (core dumped) 解决思路&#xff1a; 在主程序最开始加入两行代码&#xff1a; import faulthandler faulthandler.…

阿里 C++面试,算法题没做出来,,,

我本人是非科班学 C 后端和嵌入式的。在我面试的过程中&#xff0c;竟然得到了阿里​ C 研发工程师的面试机会。因为&#xff0c;阿里主要是用 Java 比较多&#xff0c;C 的岗位比较少​&#xff0c;所以感觉这个机会还是挺难得的。 阿里 C 研发工程师面试考了我一道类似于快速…