org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericInterface1Impl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics2.GenericInterface2 spring.test.generics2.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics2.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

Spring JIRA | Jair da Silva Ferreira Júnior | 3 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    Hi, I believe I found an issue with autowiring and generics. I can't really tell if this issue is a duplicate of [SPR-11471|https://jira.springsource.org/browse/SPR-11471], so I decided to report it anyway. The main diference with this issue is that I use the @Service annotation instead of a factory method to create the GenericInterface1Impl spring bean. I attached a simple eclipse example project to show you the issue. Here is my "application-context.xml" file: {code:xml|title=application-context.xml|borderStyle=solid} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <context:component-scan base-package="spring.test.generics2"/> </beans> {code} I have 2 classes: "GenericInterface1Impl" and "GenericInterface2Impl". "GenericInterface1Impl" depends on an implementation of "GenericInterface2". {code:title=GenericInterface1Impl.java|borderStyle=solid} @Service public class GenericInterface1Impl<T> implements GenericInterface1<T>{ @Autowired private GenericInterface2<T> gi2; @Override public String doSomethingGeneric(T o) { return gi2.doSomethingMoreGeneric(o) + "_somethingGeneric_" + o; } } {code} {code:title=GenericInterface2Impl.java|borderStyle=solid} @Service public class GenericInterface2Impl implements GenericInterface2<String>{ @Override public String doSomethingMoreGeneric(String o) { return "somethingMoreGeneric_" + o; } } {code} The issue is: spring can't find a qualifying bean for the attribute "GenericInterface1Impl.gi2" even though there's a suitable "GenericInterface2" implementation (GenericInterface2Impl) in the application context. The exact same code works perfectly with spring version 3.2.8 but fails with spring version 4.0.2. You can easily change the spring version to 3.2.8 in "pom.xml" to verify that. Here's the exception stack trace: {noformat} Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericInterface1Impl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics2.GenericInterface2 spring.test.generics2.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics2.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at spring.test.generics2.App.main(App.java:13) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics2.GenericInterface2 spring.test.generics2.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics2.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ... 13 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics2.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1100) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) ... 15 more {noformat}

    Spring JIRA | 3 years ago | Jair da Silva Ferreira Júnior
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericInterface1Impl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics2.GenericInterface2 spring.test.generics2.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics2.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  2. 0

    Hi, I believe I found an issue with autowiring and generics. I can't really tell if this issue is a duplicate of [SPR-11471|https://jira.springsource.org/browse/SPR-11471], so I decided to report it anyway. The main diference with this issue is that I use the @Service annotation instead of a factory method to create the GenericInterface1Impl spring bean. I attached a simple eclipse example project to show you the issue. Here is my "application-context.xml" file: {code:xml|title=application-context.xml|borderStyle=solid} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <context:component-scan base-package="spring.test.generics2"/> </beans> {code} I have 2 classes: "GenericInterface1Impl" and "GenericInterface2Impl". "GenericInterface1Impl" depends on an implementation of "GenericInterface2". {code:title=GenericInterface1Impl.java|borderStyle=solid} @Service public class GenericInterface1Impl<T> implements GenericInterface1<T>{ @Autowired private GenericInterface2<T> gi2; @Override public String doSomethingGeneric(T o) { return gi2.doSomethingMoreGeneric(o) + "_somethingGeneric_" + o; } } {code} {code:title=GenericInterface2Impl.java|borderStyle=solid} @Service public class GenericInterface2Impl implements GenericInterface2<String>{ @Override public String doSomethingMoreGeneric(String o) { return "somethingMoreGeneric_" + o; } } {code} The issue is: spring can't find a qualifying bean for the attribute "GenericInterface1Impl.gi2" even though there's a suitable "GenericInterface2" implementation (GenericInterface2Impl) in the application context. The exact same code works perfectly with spring version 3.2.8 but fails with spring version 4.0.2. You can easily change the spring version to 3.2.8 in "pom.xml" to verify that. Here's the exception stack trace: {noformat} Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericInterface1Impl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics2.GenericInterface2 spring.test.generics2.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics2.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at spring.test.generics2.App.main(App.java:13) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics2.GenericInterface2 spring.test.generics2.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics2.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ... 13 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics2.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1100) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) ... 15 more {noformat}

    Spring JIRA | 3 years ago | Jair da Silva Ferreira Júnior
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericInterface1Impl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics2.GenericInterface2 spring.test.generics2.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics2.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  3. 0

    Hi, I believe I found an issue with autowiring and generics. I attached a simple eclipse example project to show you the issue. Here is my "application-context.xml" file: {code:xml|title=application-context.xml|borderStyle=solid} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <context:annotation-config/> <bean class="spring.test.generics.GenericInterface1Impl" factory-method="create"/> <bean class="spring.test.generics.GenericInterface2Impl"/> </beans> {code} I have 2 classes: "GenericInterface1Impl" and "GenericInterface2Impl". "GenericInterface1Impl" depends on an implementation of "GenericInterface2". {code:title=GenericInterface1Impl.java|borderStyle=solid} public class GenericInterface1Impl<T> implements GenericInterface1<T>{ @Autowired private GenericInterface2<T> gi2; @Override public String doSomethingGeneric(T o) { return gi2.doSomethingMoreGeneric(o) + "_somethingGeneric_" + o; } /** * Factory Method * @return an instance of <code>GenericInterface1<String></code> */ public static GenericInterface1<String> create(){ return new GenericInterface1Impl<>(); } } {code} {code:title=GenericInterface2Impl.java|borderStyle=solid} public class GenericInterface2Impl implements GenericInterface2<String>{ @Override public String doSomethingMoreGeneric(String o) { return "somethingMoreGeneric_" + o; } } {code} "GenericInterface1Impl" has a factory method that creates an instance of "GenericInterface1<String>". The issue is: spring can't find a qualifying bean for the attribute "GenericInterface1.gi2" even though there's a suitable "GenericInterface2<String>" implementation (GenericInterface2Impl) in the application context. The exact same code works perfectly with spring version 3.2.8 but fails with spring version 4.0.2. You can easily change the spring version to 3.2.8 in "pom.xml" to verify that. Here's the exception stack trace: {noformat} Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.test.generics.GenericInterface1Impl#0': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics.GenericInterface2 spring.test.generics.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at spring.test.generics.App.main(App.java:13) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics.GenericInterface2 spring.test.generics.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ... 13 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1100) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) ... 15 more {noformat} Thanks, Jair Jr

    Spring JIRA | 3 years ago | Jair da Silva Ferreira Júnior
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.test.generics.GenericInterface1Impl#0': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics.GenericInterface2 spring.test.generics.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Hi, I believe I found an issue with autowiring and generics. I attached a simple eclipse example project to show you the issue. Here is my "application-context.xml" file: {code:xml|title=application-context.xml|borderStyle=solid} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <context:annotation-config/> <bean class="spring.test.generics.GenericInterface1Impl" factory-method="create"/> <bean class="spring.test.generics.GenericInterface2Impl"/> </beans> {code} I have 2 classes: "GenericInterface1Impl" and "GenericInterface2Impl". "GenericInterface1Impl" depends on an implementation of "GenericInterface2". {code:title=GenericInterface1Impl.java|borderStyle=solid} public class GenericInterface1Impl<T> implements GenericInterface1<T>{ @Autowired private GenericInterface2<T> gi2; @Override public String doSomethingGeneric(T o) { return gi2.doSomethingMoreGeneric(o) + "_somethingGeneric_" + o; } /** * Factory Method * @return an instance of <code>GenericInterface1<String></code> */ public static GenericInterface1<String> create(){ return new GenericInterface1Impl<>(); } } {code} {code:title=GenericInterface2Impl.java|borderStyle=solid} public class GenericInterface2Impl implements GenericInterface2<String>{ @Override public String doSomethingMoreGeneric(String o) { return "somethingMoreGeneric_" + o; } } {code} "GenericInterface1Impl" has a factory method that creates an instance of "GenericInterface1<String>". The issue is: spring can't find a qualifying bean for the attribute "GenericInterface1.gi2" even though there's a suitable "GenericInterface2<String>" implementation (GenericInterface2Impl) in the application context. The exact same code works perfectly with spring version 3.2.8 but fails with spring version 4.0.2. You can easily change the spring version to 3.2.8 in "pom.xml" to verify that. Here's the exception stack trace: {noformat} Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.test.generics.GenericInterface1Impl#0': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics.GenericInterface2 spring.test.generics.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at spring.test.generics.App.main(App.java:13) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics.GenericInterface2 spring.test.generics.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ... 13 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1100) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) ... 15 more {noformat} Thanks, Jair Jr

    Spring JIRA | 3 years ago | Jair da Silva Ferreira Júnior
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.test.generics.GenericInterface1Impl#0': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private spring.test.generics.GenericInterface2 spring.test.generics.GenericInterface1Impl.gi2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [spring.test.generics.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  6. 0

    unable to register a bean in container

    Stack Overflow | 3 months ago | dubey-theHarcourtians
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'beanTester': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.ttnd.springdemo.util.Triangle com.ttnd.springdemo.util.BeanTester.triangle; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.ttnd.springdemo.util.Triangle] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=triangleBean)}

  1. Dunmer 4 times, last 3 weeks ago
  2. batwalrus76 3 times, last 4 months ago
  3. Andreas Häber 2 times, last 2 months ago
  4. treefolk 1 times, last 3 months ago
  5. mauritius 2 times, last 4 months ago
26 more registered users
69 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.springframework.beans.factory.NoSuchBeanDefinitionException

    No qualifying bean of type [spring.test.generics2.GenericInterface2] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException()
  2. Spring Beans
    DefaultListableBeanFactory.preInstantiateSingletons
    1. org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1100)
    2. org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960)
    3. org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855)
    4. org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
    5. org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    6. org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    7. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    8. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    9. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    10. org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    11. org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    12. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    13. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    14. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700)
    14 frames
  3. Spring Context
    ClassPathXmlApplicationContext.<init>
    1. org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    2. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    3. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    4. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    4 frames
  4. spring.test.generics2
    App.main
    1. spring.test.generics2.App.main(App.java:13)
    1 frame