Skip to content

dubbo 2.7.7 多次注册 DubboBootstrapApplicationListener #6231

@dwhgygzt

Description

@dwhgygzt

这个问题之前版本也发现有这个问题。

Environment

  • Dubbo version: 2.7.7
  • Operating System version: window 10 springboot 2.2.6
  • Java version: 1.8

Steps to reproduce this issue

正常引入的 dubbo 2.7.7 启动报错

What actually happens?

APPLICATION FAILED TO START


Description:

The bean 'dubboBootstrapApplicationListener' could not be registered. A bean with that name has already been defined and overriding is disabled.

Action:

Debug 代码发现 DubboBootstrapApplicationListener 一共三处注册
org.apache.dubbo.config.spring.beans.factory.annotation.ServiceClassPostProcessor 中注册代码
// ------------------------------129行-----------------------------------------
// @SInCE 2.7.5
registerBeans(registry, DubboBootstrapApplicationListener.class);
// -----------------------------------------------------------------------

org.apache.dubbo.config.spring.context.annotation.DubboConfigConfigurationRegistrar
// ------------------------------56行-----------------------------------------
// Since 2.7.6
registerCommonBeans(registry);
// -----------------------------------------------------------------------

org.apache.dubbo.config.spring.context.annotation.DubboComponentScanRegistrar
// ------------------------------61行-----------------------------------------
// Since 2.7.6
registerCommonBeans(registry);
// -----------------------------------------------------------------------

以上 registerCommonBeans 方法没啥问题 , 该方法中注册DubboBootstrapApplicationListener的代码是
// Since 2.7.4 Register DubboBootstrapApplicationListener as an infrastructure Bean
registerInfrastructureBean(registry, DubboBootstrapApplicationListener.BEAN_NAME,
DubboBootstrapApplicationListener.class);
这个registerInfrastructureBean方法里面有是否已经注册过的Bean判断,

ServiceClassPostProcessor 中的 registerBeans 没有判断是否相同的Bean是否已经注册过,导致抛出 BeanDefinitionOverrideException

建议相关代码统一全部调用 BeanRegistrar中的 registerInfrastructureBean 这个方法。

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions