org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/classes/springContext.xml]; nested exception is java.lang.IllegalStateException: Annotation-specified bean name 'cardController' for bean class [com.qdzq.wlpt.controller.api.CardController] conflicts with existing, non-compatible bean definition of same name and class [com.qdzq.wlpt.controller.admin.CardController]
不同包下的文件不是可以重名吗?
You used Spring’s Annotation,
@Controller
标记的bean的id为类名(首字母小写),这两个CardController的bean id均为cardController
, so the id conflictYou can post your xml file and have a look
You have two CardControllers. After automatic injection, the bean IDs will conflict. If you want both, configure two beans in the spring file and set them to different IDs, so there will be no conflict. Spring defaults to the bean ID. The first letter of the class name is lowercase
For Auto-Scan, the Controller does not allow duplicate names by default, as does Service and Dao.
If the default class is ClassName, the beanID is className.
You can customize the bean id, @Service("xxxService"), the Controller has not been repeated, and it should be handled in the same way.