conflicts with existing, non-compatible bean definition of same name and class after proguard obfuscation

旧时模样 提交于 2019-12-21 23:02:08

问题


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.


回答1:


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 {

}



回答2:


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).




回答3:


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.



来源:https://stackoverflow.com/questions/10299895/conflicts-with-existing-non-compatible-bean-definition-of-same-name-and-class-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!