springboot與dubbo的版本匹配問題
springboot與dubbo的版本匹配
參考:
項目里原始版本
- springboot:2.1.6.RELEASE
- dubbo-spring-boot-starter : 0.2.1.RELEASE
- dubbo: 2.6.5
上面這么寫是可以正常運行的。但是當(dāng)把dubbo升級到2.6.7時候,卻報錯了,異常如下:
升級到2.6.7后錯誤日志
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
后來經(jīng)過嘗試,把springboot的版本下調(diào)到2.0.9時候,項目可以正常啟動。
所以得到下面這個版本匹配的結(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版本對應(yīng)關(guān)系
背景
springboot 和 dubbo 在 pom.xml 中的版本是有對應(yīng)關(guān)系的,如果配置的依賴不按照對應(yīng)關(guān)系配置的話項目啟動就會報錯,報錯的信息如下所示:
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]
對應(yīng)關(guān)系
我在項目中使用的阿里巴巴的 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>
則對應(yīng)的使用 spring-boot-starter-parent 的版本號是 2.1.6.RELEASE ,這樣配置依賴的話,項目啟動是沒有問題的。
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 的所有版本信息。
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Java之?dāng)?shù)組在指定位置插入元素實現(xiàn)
本文主要介紹了Java之?dāng)?shù)組在指定位置插入元素實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-01-01IDEA 2020.1 搜索不到Chinese (Simplified) Language
小編在安裝中文插件時遇到IDEA 2020.1 搜索不到Chinese ​(Simplified)​ Language Pack EAP,無法安裝的問題,本文給大家分享我的解決方法,感興趣的朋友一起看看吧2020-04-04Java中使用Preferences 的 API設(shè)置用戶偏好
這篇文章主要介紹了Java中使用Preferences 的 API設(shè)置用戶偏好的方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-09-09淺談Java代碼的 微信長鏈轉(zhuǎn)短鏈接口使用 post 請求封裝Json(實例)
下面小編就為大家?guī)硪黄獪\談Java代碼的 微信長鏈轉(zhuǎn)短鏈接口使用 post 請求封裝Json(實例)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-07-07JAVA中l(wèi)ist,set,數(shù)組之間的轉(zhuǎn)換詳解
以下是對JAVA中l(wèi)ist,set,數(shù)組之間的轉(zhuǎn)換進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以過來參考下2013-09-09Java中的線程同步與ThreadLocal無鎖化線程封閉實現(xiàn)
這篇文章主要介紹了Java中的線程同步與ThreadLocal無鎖化線程封閉實現(xiàn),Synchronized關(guān)鍵字與ThreadLocal變量的使用是Java中線程控制的基礎(chǔ),需要的朋友可以參考下2016-03-03Java實現(xiàn)單鏈表SingleLinkedList增刪改查及反轉(zhuǎn) 逆序等
單鏈表是鏈表的其中一種基本結(jié)構(gòu)。一個最簡單的結(jié)點結(jié)構(gòu)如圖所示,它是構(gòu)成單鏈表的基本結(jié)點結(jié)構(gòu)。在結(jié)點中數(shù)據(jù)域用來存儲數(shù)據(jù)元素,指針域用于指向下一個具有相同結(jié)構(gòu)的結(jié)點。 因為只有一個指針結(jié)點,稱為單鏈表2021-10-10