I\'m having a problem with some Spring bean definitions. I have a couple of context xml files that are being loaded by my main() method, and both of them contain almost exclusiv
I had a similar problem, with two jar libraries (app1 and app2) in one project. The bean "BeanName" is defined in app1 and is extended in app2 and the bean redefined with the same name.
In app1:
package com.foo.app1.pkg1;
@Component("BeanName")
public class Class1 { ... }
In app2:
package com.foo.app2.pkg2;
@Component("BeanName")
public class Class2 extends Class1 { ... }
This causes the ConflictingBeanDefinitionException
exception in the loading of the applicationContext due to the same component bean name.
To solve this problem, in the Spring configuration file applicationContext.xml
:
So the Class1 is excluded to be automatically component-scanned and assigned to a bean, avoiding the name conflict.