16
votes

I have the configuration like below:

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

and during application context startup I receive something like this in the log:

[INFO] [] [] Overriding bean definition for bean 'reconciliationJob': replacing [Generic bean: class [org.springframework.batch.core.configuration.xml.SimpleFlowFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.springframework.batch.core.configuration.xml.JobParserJobFactoryBean]; scope=; 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 overriding problem?

5
is there a way to get rid of these log messages?OhadR

5 Answers

7
votes

I got the same error. My problem was that I marked the class with @Service then in one of the @Configuration classes I created a @Bean out of it with the same name as the class.

3
votes

This is not an error, is only an [INFO] and is a substitution done by Spring; you can see something similar about "step" scoped beans.
For example, if you have a bean marked as

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

this will be replaced by a bean with name scopedTarget.myBean.
Lookup at StepScope doc and source

3
votes

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

This can happen when for example your have duplicate/overriding <context-param> imports in your WEB.xml.

To solve the issue leave only the root applicationContext.xml there and remove the children.

1
votes

I experienced something similar and I just changed the name of the class and it worked. Still can't figure out why. I'll update if I understand it better.

But start with changing the bean's class name.

-2
votes

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

Note: take care when removing the dependencies because the result of dependency:analyze it is not secure .