peachyy opened a new issue, #11080:
URL: https://github.com/apache/dubbo/issues/11080

   
   ### Environment
   
   * Dubbo version: 2.7.13 升级到3.0.11
   * Operating System version: window
   * Java version: 1.8
   
   ### Steps to reproduce this issue 重现此问题的步骤
   
   1. 当一个应用实例的某个接口在本应用中用    `@Autowired` 注入过,并且在本应用其他的业务用`@DubboReference` 过。
   2. 因为历史项目原因 `@Autowired`定义的属性名不是很规范 spring容器是按照类型查找。这种就会出现2个type一样的bean 
就报错了,此现状在2.7.13中是正常能跑的
   
   示例如下 
   
https://github.com/apache/dubbo-samples.git/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider
   把dubbo版本改为3.0.11 samples默认的这个版本应该也是有问题的。
   新增`IDemoService2.java` `DemoService2Impl.java` 
   
   IDemoService2.java 接口定义
   
   ``` java  
    public interface IDemoService2 {
   }
   ```
   
   DemoService2Impl.java 接口实现
   
   ``` java 
   @DubboService
   public class DemoService2Impl implements IDemoService2 {
       @Autowired
       private DemoService demoService;
   
       @DubboReference
       private DemoService demoServiceRemote;
       public void tet(){
   
       }
   }
   ```
   
   启动异常
   
   `022-12-06 10:58:38.011  WARN 26068 --- [           main] 
s.c.a.AnnotationConfigApplicationContext : Exception encountered during context 
initialization - cancelling refresh attempt: 
org.springframework.beans.factory.UnsatisfiedDependencyException: Error 
creating bean with name 'demoService2': Unsatisfied dependency expressed 
through field 'demoService'; nested exception is 
org.springframework.beans.factory.NoUniqueBeanDefinitionException: No 
qualifying bean of type 'org.apache.dubbo.springboot.demo.DemoService' 
available: expected single matching bean but found 2: 
demoServiceImpl,demoServiceRemote
   2022-12-06 10:58:38.020  INFO 26068 --- [           main] 
ConditionEvaluationReportLoggingListener : 
   
   Error starting ApplicationContext. To display the conditions report re-run 
your application with 'debug' enabled.
   2022-12-06 10:58:38.023 ERROR 26068 --- [           main] 
o.s.b.d.LoggingFailureAnalysisReporter   : 
   
   ***************************
   APPLICATION FAILED TO START
   ***************************
   
   Description:
   
   Field demoService in org.apache.dubbo.springboot.demo.provider.DemoService2 
required a single bean, but 2 were found:
        - demoServiceImpl: defined in file 
[D:\opensource\dubbo-samples\1-basic\dubbo-samples-spring-boot\dubbo-samples-spring-boot-provider\target\classes\org\apache\dubbo\springboot\demo\provider\DemoServiceImpl.class]
        - demoServiceRemote: defined in null
   
   
   Action:
   
   Consider marking one of the beans as @Primary, updating the consumer to 
accept multiple beans, or using @Qualifier to identify the bean that should be 
consumed
   `
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to