springboot與dubbo的版本匹配問(wèn)題
springboot與dubbo的版本匹配
參考:

項(xiàng)目里原始版本
- springboot:2.1.6.RELEASE
- dubbo-spring-boot-starter : 0.2.1.RELEASE
- dubbo: 2.6.5
上面這么寫是可以正常運(yùn)行的。但是當(dāng)把dubbo升級(jí)到2.6.7時(shí)候,卻報(bào)錯(cuò)了,異常如下:
升級(jí)到2.6.7后錯(cuò)誤日志
Description:
The bean 'dubboConfigConfiguration.Single', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
后來(lái)經(jīng)過(guò)嘗試,把springboot的版本下調(diào)到2.0.9時(shí)候,項(xiàng)目可以正常啟動(dòng)。
所以得到下面這個(gè)版本匹配的結(jié)論:
2.7版本以下的,使用的是alibaba目錄下的jar,
springbootdubbo-springdubbo注1.x0.1.2.RELEASE2.6.5+2.6.6以上的dubbo需要配置netty-alljar包2.0.0~2.0.90.2.1.RELEASE2.6.5/2.6.6/2.6.72.1.x0.2.1.RELEASE2.6.5 /2.7.1
2.7版本以上的,用apache目錄下面的jar,dubbo-spring和dubbo都使用apache下面的版本,統(tǒng)一使用2.7即可,springboot也可以用2.1.x以上
springboot+dubbo版本對(duì)應(yīng)關(guān)系
背景
springboot 和 dubbo 在 pom.xml 中的版本是有對(duì)應(yīng)關(guān)系的,如果配置的依賴不按照對(duì)應(yīng)關(guān)系配置的話項(xiàng)目啟動(dòng)就會(huì)報(bào)錯(cuò),報(bào)錯(cuò)的信息如下所示:
java.lang.IllegalStateException: Cannot load configuration class: com.alibaba.boot.dubbo.autoconfigure.DubboAutoConfiguration
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:403) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:249) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:283) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:127) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at com.ProviderApplication.main(ProviderApplication.java:13) [classes/:na]
對(duì)應(yīng)關(guān)系
我在項(xiàng)目中使用的阿里巴巴的 dubbo-spring-boot-starter 版本是 0.2.0 ,maven 依賴如下所示:
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>0.2.0</version>
</dependency>
則對(duì)應(yīng)的使用 spring-boot-starter-parent 的版本號(hào)是 2.1.6.RELEASE ,這樣配置依賴的話,項(xiàng)目啟動(dòng)是沒(méi)有問(wèn)題的。
| Dubbo Spring Boot | Dubbo | Spring Boot |
| 0.2.1.RELEASE | 2.6.5+ | 2.x |
| 0.1.2.RELEASE | 2.6.5+ | 1.x |
可以在 https://mvnrepository.com/artifact/com.alibaba.boot/dubbo-spring-boot-starter 里面查看 dubbo 的所有版本信息。
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- 教你springboot+dubbo快速啟動(dòng)的方法
- IDEA整合Dubbo+Zookeeper+SpringBoot實(shí)現(xiàn)
- spring/springboot整合dubbo詳細(xì)教程
- SpringBoot通過(guò)整合Dubbo解決@Reference注解問(wèn)題
- springboot+dubbo+validation 進(jìn)行rpc參數(shù)校驗(yàn)的實(shí)現(xiàn)方法
- SpringBoot與Dubbo整合的方式詳解
- springboot+dubbo啟動(dòng)項(xiàng)目時(shí)報(bào)錯(cuò) zookeeper not connected的問(wèn)題及解決方案
相關(guān)文章
Java之?dāng)?shù)組在指定位置插入元素實(shí)現(xiàn)
本文主要介紹了Java之?dāng)?shù)組在指定位置插入元素實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-01-01
IDEA 2020.1 搜索不到Chinese (Simplified) Language
小編在安裝中文插件時(shí)遇到IDEA 2020.1 搜索不到Chinese ​(Simplified)​ Language Pack EAP,無(wú)法安裝的問(wèn)題,本文給大家分享我的解決方法,感興趣的朋友一起看看吧2020-04-04
Java中使用Preferences 的 API設(shè)置用戶偏好
這篇文章主要介紹了Java中使用Preferences 的 API設(shè)置用戶偏好的方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09
淺談Java代碼的 微信長(zhǎng)鏈轉(zhuǎn)短鏈接口使用 post 請(qǐng)求封裝Json(實(shí)例)
下面小編就為大家?guī)?lái)一篇淺談Java代碼的 微信長(zhǎng)鏈轉(zhuǎn)短鏈接口使用 post 請(qǐng)求封裝Json(實(shí)例)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-07-07
JAVA中l(wèi)ist,set,數(shù)組之間的轉(zhuǎn)換詳解
以下是對(duì)JAVA中l(wèi)ist,set,數(shù)組之間的轉(zhuǎn)換進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以過(guò)來(lái)參考下2013-09-09
Java中的線程同步與ThreadLocal無(wú)鎖化線程封閉實(shí)現(xiàn)
這篇文章主要介紹了Java中的線程同步與ThreadLocal無(wú)鎖化線程封閉實(shí)現(xiàn),Synchronized關(guān)鍵字與ThreadLocal變量的使用是Java中線程控制的基礎(chǔ),需要的朋友可以參考下2016-03-03
Java實(shí)現(xiàn)單鏈表SingleLinkedList增刪改查及反轉(zhuǎn) 逆序等
單鏈表是鏈表的其中一種基本結(jié)構(gòu)。一個(gè)最簡(jiǎn)單的結(jié)點(diǎn)結(jié)構(gòu)如圖所示,它是構(gòu)成單鏈表的基本結(jié)點(diǎn)結(jié)構(gòu)。在結(jié)點(diǎn)中數(shù)據(jù)域用來(lái)存儲(chǔ)數(shù)據(jù)元素,指針域用于指向下一個(gè)具有相同結(jié)構(gòu)的結(jié)點(diǎn)。 因?yàn)橹挥幸粋€(gè)指針結(jié)點(diǎn),稱為單鏈表2021-10-10

