Override bean definition for bean 'X': replacement [Generic bean Y]

I have a configuration like below:

batch:job id="reconciliationJob" job-repository="jobRepository" restartable="true" 

and while running the application context, I get something like this in the log:

[INFO] [] [] Overriding the bean definition for a bean 'reconciliationJob': replacement [Generic bean: class [org.springframework.batch.core.configuration.xml.SimpleFlowFactoryBean]; Volume =; abstract = false; lazyInit = false; autowireMode = 0; dependencyCheck = 0; autowireCandidate = TRUE; primary = false; factoryBeanName = NULL; factoryMethodName = NULL; initMethodName = NULL; destroyMethodName = null] using [Generic bean: class [org.springframework.batch.core.configuration.xml.JobParserJobFactoryBean]; Volume =; abstract = false; lazyInit = false; autowireMode = 0; dependencyCheck = 0; autowireCandidate = TRUE; primary = false; factoryBeanName = NULL; factoryMethodName = NULL; initMethodName = NULL; destroyMethodName = NULL]

How can I solve this problem?

+8
source share
5 answers

I got the same error. My problem was that I marked the class using @Service, and then in one of the @Configuration classes, I broke @ Bean from it with the same name as the class.

+4
source

This happens when Spring parses the same applicationContext.xml twice.

This can happen if, for example, you have a duplicate / override of the <context-param> import in WEB.xml .

To solve the problem, leave only the root applicationContext.xml and remove the children.

+3
source

This is not a mistake, it is only [INFO] and is a replacement made by Spring; you can see something like this in the beans step area.
For example, if you have a bean marked as

 <bean id="myBean" class="path.to.beanClass" scope="step" /> 

it will be replaced with a bean named scopedTarget.myBean .
Search StepScope doc and source

+1
source

I experienced something similar, and I just changed the name of the class, and it worked. Still can't understand why. I will clarify if I understand better.

But start by changing the bean class name.

0
source

I had a similar problem and resolved it with dependency:analyze in run maven -> goal. I found unused dependencies in my pom and I removed unused dependencies.

Note. Be careful when removing dependencies, because the result of dependency:analyze not safe.

-1
source

Source: https://habr.com/ru/post/954657/


All Articles