Dubbo 之四 Dubbo 开发随笔

SpringBoot-2.1.0+ 整合 Apache Dubbo-2.7.0,启动应用后提示需要添加 SpringBoot 配置 “spring.main.allow-bean-definition-overriding=true”

异常日志:

1
2
3
4
5
6
7
8
9
10
11
***************************
APPLICATION FAILED TO START
***************************

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

异常分析:

1
2
3
问题是由注解 @EnableDubbo、@EnableDubboConfig 的使用所导致,具体可参考以下资料:
https://github.com/apache/dubbo/issues/3193
https://github.com/apache/dubbo-spring-boot-project/issues/476

解决方法:

1
2
3
4
5
方法一:
往SpringBoot的配置文件(application.properties)中添加对应配置,允许在Spring容器内可以覆盖Bean的定义: spring.main.allow-bean-definition-overriding=true

方法二:
将Apache Dubbo-2.7.0 升级到 Apache Dubbo-2.7.1版本,具体可参考:https://github.com/apache/dubbo-spring-boot-project/issues/467