apache / apache/dubbo

BeanNotOfRequiredTypeException when using spring bean injection

Open
#12,637 16 comments 0 reactions 0 assignees View on GitHub
component/sdk good first issue help wanted type/enhancement
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

- Dubbo version: 3.2.2
- Java version: 1.8
- SpringBoot: 2.7.13

[前面也讨论过这个问题](https://github.com/apache/dubbo/issues/10443)

3.X ReferenceAnnotationBeanPostProcessor 按@DubboReference属性名注册别名
![image](https://github.com/apache/dubbo/assets/20903014/dc65e128-a484-4980-8e97-101bbfa96584)
![image](https://github.com/apache/dubbo/assets/20903014/36a0d6ec-e987-474d-8094-18e18eba893d)
这样会导致在不同的类中注入不同类型的Bean时必须要用不同的属性名称,如果像下面这样就会导致异常
![image](https://github.com/apache/dubbo/assets/20903014/b7271a32-6252-4c79-9710-4366d3fa8849)
![image](https://github.com/apache/dubbo/assets/20903014/fb9f7df7-20b7-404c-b2b5-ce4efa5160d2)
![image](https://github.com/apache/dubbo/assets/20903014/d7089727-f8e1-4cc5-a5d8-8cd68517c56d)
**dubbo2.x 就没有这个问题,3.0中使用属性名注册别名是有什么特殊的用意吗?**
我理解这与spring并没有关系 https://github.com/apache/dubbo/issues/10443#issuecomment-1212703407,
因为我只要不用 dubbo3.x 就不会导致异常。
@chickenlj

Contributor guide

Open the contributing guide

Research direction

Start by reviewing issue #10443 and the reproduction details and screenshots here, then compare the reported Dubbo 2.x and 3.x bean-injection behavior under Java 8 and Spring Boot 2.7.13. Done means injecting different bean types with the same property name no longer raises BeanNotOfRequiredTypeException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.