服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - Java教程 - springboot与dubbo的版本匹配问题

springboot与dubbo的版本匹配问题

2022-02-17 15:25EmineWang Java教程

这篇文章主要介绍了springboot与dubbo的版本匹配问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

springbootdubbo的版本匹配

官方链接

参考:

springboot与dubbo的版本匹配问题

项目里原始版本

  • springboot:2.1.6.RELEASE
  • dubbo-spring-boot-starter : 0.2.1.RELEASE
  • dubbo: 2.6.5

上面这么写是可以正常运行的。但是当把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

后来经过尝试,把springboot的版本下调到2.0.9时候,项目可以正常启动。

所以得到下面这个版本匹配的结论:

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下面的版本,统一使用2.7即可,springboot也可以用2.1.x以上

springboot+dubbo版本对应关系

背景

springboot 和 dubbo 在 pom.xml 中的版本是有对应关系的,如果配置的依赖不按照对应关系配置的话项目启动就会报错,报错的信息如下所示:

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]

对应关系

我在项目中使用的阿里巴巴的 dubbo-spring-boot-starter 版本是 0.2.0 ,maven 依赖如下所示:

?
1
2
3
4
5
<dependency>
    <groupId>com.alibaba.boot</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>0.2.0</version>
</dependency>

则对应的使用 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 的所有版本信息。

以上为个人经验,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/a718515028/article/details/98067864

延伸 · 阅读

精彩推荐