apache / apache/dubbo

混合使用注解和XML配置导致出现两个application实例(Mixing annotations and XML configuration results in two instances of application)

Open
#10,362 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

### Environment

* Dubbo version: 2.7.16
* Operating System version: Window 10
* Java version: 1.8

### Steps to reproduce this issue
我并没有使用3.0以上版本,因为和其他的组件兼容性还不够好(I didn't use version 3.0 or above because the compatibility with other components was not good enough)
1. 我使用@EnableDubbo和@DubboReference注解注入我需要的Spring bean,dubbo的application 和registry信息使用XML 配置,并使用@ImportResource加载此XML配置(I inject Spring beans using @EnableDubbo and @DubboReference, the application and registry information is configured using XML, and I use @ImportResource to load this XML configuration)
2. 在运行项目后出现此错误(I got this error after running the project):org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.apache.dubbo.config.ApplicationConfig' available: expected single matching bean but found 2: demo-consumer,org.apache.dubbo.config.ApplicationConfig#0
3. 出现了两个application实例(There are two application instances)

我给出实现上述错误的案例代码配置(I give the configuration of the case code that achieves the above error:):

`
@EnableDubbo
@SpringBootApplication
@ImportResource(value = "classpath:spring/dubbo-demo-consumer.xml")
public class ConsumerApplication {
public static void main(String[] args) {
SpringApplication.run(ConsumerApplication.class, args);
}
}
`

`




`

`@RestController
public class TestController {
@DubboReference
private DemoService demoService;
}`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.