io.dubbo.springboot版本不兼容dubbo-2.5.3

遇到問題:
在dubbo整合springboot的時(shí)候苗缩,使用io.dubbo.springboot的jar包,配合的是dubbo2.5.3的版本,會(huì)出現(xiàn)Bean創(chuàng)建失敗的錯(cuò)誤寸五。

SpringBoot 整合 Dubbo + Zookeeper :https://github.com/i-Javan/springboot

pom:

<!--   SpringBoot 整合 Dubbo 依賴 -->
<dependency>
     <groupId>io.dubbo.springboot</groupId>
     <artifactId>spring-boot-starter-dubbo</artifactId>
     <version>1.0.0</version>
</dependency>

報(bào)錯(cuò)代碼:

public class DubboServiceImpl implements DubboService{

    public List<User> getList() {
        return Arrays.asList(new User[]{new User("1","小紅","18","18@qq.com"),new User("1","?","17","17@qq.com")});
    }

    public User getById(String id) {
        return new User("1","小紅","18","18@qq.com");
    }

}

錯(cuò)誤信息:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-02-26 10:58:23.439 ERROR 13992 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dubboServiceImpl' defined in file [E:\work space\movebrick\movebrick-zookeeper-dubbo-server\target\classes\com\movebrick\dubbo\module\service\impl\DubboServiceImpl.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at com.movebrick.dubbo.ServerApplication.main(ServerApplication.java:18) [classes/:na]
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at org.I0Itec.zkclient.ZkClient.<clinit>(ZkClient.java:63) ~[zkclient-0.7.jar:0.7]
    at com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkclientZookeeperClient.<init>(ZkclientZookeeperClient.java:25) ~[dubbo-2.5.3.jar:2.5.3]
    at 

報(bào)錯(cuò)原因:因?yàn)?.5.3版本的dubbo增加了ServiceBean,applicationEventPublisher,初始化報(bào)錯(cuò).

Spring Boot自帶的Dubbo版本與io.dubbo.springboot有沖突旁蔼,可以查看io.dubbo.springboot 的Maven庫找到對(duì)應(yīng)的Dubbo版本與之對(duì)應(yīng)锨苏。

依賴:

解決方法一:

如果使用 io.dubbo.springboot這個(gè)包疙教,則搭配dubbo 2.6.2以下的版本:

<!-- https://mvnrepository.com/artifact/com.alibaba/dubbo -->
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>dubbo</artifactId>
    <version>2.6.2</version>
</dependency>

解決方法二:

使用官方正常維護(hù)的Springboot-dubbo, com.alibaba.boot,則dubbo版本都可以兼容

<!-- https://mvnrepository.com/artifact/com.alibaba.boot/dubbo-spring-boot-starter -->
<dependency>
    <groupId>com.alibaba.boot</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>0.2.0</version>
</dependency>

SpringBoot 整合 Dubbo + Zookeeper :https://github.com/i-Javan/springboot
SpringBoot 整合 Reids :https://github.com/i-Javan/springboot/tree/master/movebrick-mybatis-annotation
SpringBoot 整合 Mybatis :https://github.com/i-Javan/springboot/tree/master/movebrick-mybatis
SpringBoot 整合 MybatisPlus :https://github.com/i-Javan/springboot/tree/master/movebrick-mybatisPlus
SpringBoot 整合 MybatisAnnotation :https://github.com/i-Javan/springboot/tree/master/movebrick-mybatis-annotation
SpringBoot 整合 Elasticsearch:https://github.com/i-Javan/springboot/tree/master/movebrick-elasticsearch
SpringBoot 整合 ActiveMQ:https://github.com/i-Javan/springboot/tree/master/movebrick-activeMQ

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市伞租,隨后出現(xiàn)的幾起案子贞谓,更是在濱河造成了極大的恐慌,老刑警劉巖葵诈,帶你破解...
    沈念sama閱讀 222,104評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件裸弦,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡作喘,警方通過查閱死者的電腦和手機(jī)理疙,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,816評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來泞坦,“玉大人沪斟,你說我怎么就攤上這事∠窘茫” “怎么了主之?”我有些...
    開封第一講書人閱讀 168,697評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)李根。 經(jīng)常有香客問我槽奕,道長(zhǎng),這世上最難降的妖魔是什么房轿? 我笑而不...
    開封第一講書人閱讀 59,836評(píng)論 1 298
  • 正文 為了忘掉前任粤攒,我火速辦了婚禮,結(jié)果婚禮上囱持,老公的妹妹穿的比我還像新娘夯接。我一直安慰自己,他們只是感情好纷妆,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,851評(píng)論 6 397
  • 文/花漫 我一把揭開白布盔几。 她就那樣靜靜地躺著,像睡著了一般掩幢。 火紅的嫁衣襯著肌膚如雪逊拍。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,441評(píng)論 1 310
  • 那天际邻,我揣著相機(jī)與錄音芯丧,去河邊找鬼。 笑死世曾,一個(gè)胖子當(dāng)著我的面吹牛缨恒,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 40,992評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼骗露,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼岭佳!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起椒袍,我...
    開封第一講書人閱讀 39,899評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤驼唱,失蹤者是張志新(化名)和其女友劉穎藻茂,沒想到半個(gè)月后驹暑,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,457評(píng)論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡辨赐,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,529評(píng)論 3 341
  • 正文 我和宋清朗相戀三年优俘,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片掀序。...
    茶點(diǎn)故事閱讀 40,664評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡帆焕,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出不恭,到底是詐尸還是另有隱情叶雹,我是刑警寧澤,帶...
    沈念sama閱讀 36,346評(píng)論 5 350
  • 正文 年R本政府宣布换吧,位于F島的核電站折晦,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏沾瓦。R本人自食惡果不足惜满着,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,025評(píng)論 3 334
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望贯莺。 院中可真熱鬧风喇,春花似錦、人聲如沸缕探。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,511評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽爹耗。三九已至豁鲤,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間鲸沮,已是汗流浹背琳骡。 一陣腳步聲響...
    開封第一講書人閱讀 33,611評(píng)論 1 272
  • 我被黑心中介騙來泰國(guó)打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留讼溺,地道東北人楣号。 一個(gè)月前我還...
    沈念sama閱讀 49,081評(píng)論 3 377
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親炫狱。 傳聞我的和親對(duì)象是個(gè)殘疾皇子藻懒,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,675評(píng)論 2 359