org.springframework.beans.factory.BeanCreationException

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

Check Servers Launch Configuration in Eclipse. See the details below.

tip

Spring expects that the EntityManagerFactory has to be called "entityManagerFactory". It uses convention over configuration to make it easier to use.

tip

Add slf4j dependency to your pom.xml

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • Hello, I have several jobs defined. Then I want to test them so I create a bean of type {{JobLauncherTestUtils}} inside my config: {code} @Bean(name = "ncsvjobLauncherTestUtils") public JobLauncherTestUtils defaultJobLauncherTestUtils() { JobLauncherTestUtils result = new JobLauncherTestUtils(); result.setJob(context.getBean("ncsvImportJob", Job.class)); return result; } {code} However when I run my tests I get this exception: {code} ption is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.batch.test.JobLauncherTestUtils.setJob(org.springframework.batch.core.Job); nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.batch.core.Job] is defined: expected single matching bean but found 3: ncsvImportJob,syncEntityJob,syncCatalogJob at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) {code} This is because the {{JobLauncherTestUtils}} the {{setJob}} method has the {{@Autowired}} annotation so it will try to autowire the job, but as I said I have several.
    via by Petar Tahchiev,
  • Hello, I have several jobs defined. Then I want to test them so I create a bean of type {{JobLauncherTestUtils}} inside my config: {code} @Bean(name = "ncsvjobLauncherTestUtils") public JobLauncherTestUtils defaultJobLauncherTestUtils() { JobLauncherTestUtils result = new JobLauncherTestUtils(); result.setJob(context.getBean("ncsvImportJob", Job.class)); return result; } {code} However when I run my tests I get this exception: {code} ption is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.batch.test.JobLauncherTestUtils.setJob(org.springframework.batch.core.Job); nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.batch.core.Job] is defined: expected single matching bean but found 3: ncsvImportJob,syncEntityJob,syncCatalogJob at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) {code} This is because the {{JobLauncherTestUtils}} the {{setJob}} method has the {{@Autowired}} annotation so it will try to autowire the job, but as I said I have several.
    via by Petar Tahchiev,
  • SpringBoot application crash
    via Stack Overflow by Aleksandrs Rudzitis
    ,
    • org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.batch.test.JobLauncherTestUtils.setJob(org.springframework.batch.core.Job); nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.batch.core.Job] is defined: expected single matching bean but found 3: ncsvImportJob,syncEntityJob,syncCatalogJob at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)

    Users with the same issue

    rp
    1 times, last one,
    Unknown visitor1 times, last one,
    linxiaolong
    3 times, last one,
    tfr
    2 times, last one,
    qavid
    24 times, last one,
    113 more bugmates