2
votes

after Proguard obfuscation i get the following error :

Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.IllegalStateException: Annotation-specified bean name 'a' for bean class [com.company.project.b.a.a.a] conflicts with existing, non-compatible bean definition of same name and class [com.company.project.a.a]

i'm using annotation based spring configuration , how can i avoid having two classes with the same name using Proguard because Spring doesn't allow two beans to have the same name.

3

3 Answers

16
votes

I'm not sure if this is what you want, but you can specify bean name in @Component (and stereotypes @Repository, @Service and @Controller) value:

@Component("myBeanName")
public class MyBean {

}
3
votes

I had the same problem and nothing else was helping out. Sometimes the problem occurs if you have moved your classes around and it refers to old classes, even if they don't exist.

In this case, just do this :

mvn eclipse:clean

mvn eclipse:eclipse

This worked well for me.

1
votes

Another cause; you may have different versions of Spring in your classpath, for example, spring 2.x with spring 3.x. In such condition, beans seem to be loaded twice. If you use maven, check if a module does not import an old version of Spring (mvn dependency:tree) and remove it by excluding the involved spring artifact (exclusions).