You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/04/10 02:53:54 UTC

[GitHub] [servicecomb-java-chassis] zhongyi-tim opened a new issue #1706: springboot2+cse,启动类添加@EnableServiceComb注解,报错: CseApplicationListener有多个实现,无法注入

zhongyi-tim opened a new issue #1706: springboot2+cse,启动类添加@EnableServiceComb注解,报错: CseApplicationListener有多个实现,无法注入
URL: https://github.com/apache/servicecomb-java-chassis/issues/1706
 
 
   具体报错如下:
   2020-04-10 02:51:14,251Z(25160):ERROR{}[main]com.huawei.m2m.cmp.global.simcard.SimMgmtApplication.main(SimMgmtApplication.java:55)-->start error: Error creating bean with name 'serviceCombSpringConfiguration': Unsatisfied dependency expressed through method 'setCseApplicationListener' parameter 0; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.apache.servicecomb.core.CseApplicationListener' available: expected single matching bean but found 2: org.apache.servicecomb.core.CseApplicationListener#0,org.apache.servicecomb.core.CseApplicationListener#1
   org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'serviceCombSpringConfiguration': Unsatisfied dependency expressed through method 'setCseApplicationListener' parameter 0; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.apache.servicecomb.core.CseApplicationListener' available: expected single matching bean but found 2: org.apache.servicecomb.core.CseApplicationListener#0,org.apache.servicecomb.core.CseApplicationListener#1
   	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:676) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1395) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
   	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
   	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
   	at com.huawei.m2m.cmp.base.starter.AbstractApplicationStarter.beforeProcess(AbstractApplicationStarter.java:65) ~[classes/:?]
   	at com.huawei.m2m.cmp.global.simcard.SimMgmtApplication.main(SimMgmtApplication.java:50) ~[classes/:?]
   Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.apache.servicecomb.core.CseApplicationListener' available: expected single matching bean but found 2: org.apache.servicecomb.core.CseApplicationListener#0,org.apache.servicecomb.core.CseApplicationListener#1
   	at org.springframework.beans.factory.config.DependencyDescriptor.resolveNotUnique(DependencyDescriptor.java:221) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1225) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:668) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
   	... 20 more

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1706: springboot2+cse,启动类添加@EnableServiceComb注解,报错: CseApplicationListener有多个实现,无法注入

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1706: springboot2+cse,启动类添加@EnableServiceComb注解,报错: CseApplicationListener有多个实现,无法注入
URL: https://github.com/apache/servicecomb-java-chassis/issues/1706#issuecomment-611900761
 
 
   有可能是 pom 配置不对,导致 bean 被加载了两次。 或者是运行于 tomcat 环境, web.xml 配置不对,导致了 bean 被加载了两次。 
   
   可以看下这个 [starter 说明](https://docs.servicecomb.io/java-chassis/zh_CN/using-java-chassis-in-spring-boot/components-for-spring-boot/),和对应的示例

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1706: springboot2+cse,启动类添加@EnableServiceComb注解,报错: CseApplicationListener有多个实现,无法注入

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1706: springboot2+cse,启动类添加@EnableServiceComb注解,报错: CseApplicationListener有多个实现,无法注入
URL: https://github.com/apache/servicecomb-java-chassis/issues/1706#issuecomment-613749683
 
 
   问题原因之一:
   
   @ImportResource(classpath*:META-INF/spring/*.bean.xml) 这个被重复声明了。
   @EnableServiceComb里面声明了一次,产品自定义的注解又声明了一次,导致重复加载bean
   
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services