org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'BusinessAccountController' for bean class [com.hs.BusinessAccountController] conflicts with existing, non-compatible bean definition of same name and class [com.hs.BusinessAccountController] at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.checkCandidate(ClassPathBeanDefinitionScanner.java:314) at org.mybatis.spring.mapper.ClassPathMapperScanner.checkCandidate(ClassPathMapperScanner.java:223) at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:253) at org.mybatis.spring.mapper.ClassPathMapperScanner.doScan(ClassPathMapperScanner.java:155) at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.scan(ClassPathBeanDefinitionScanner.java:220)
问题的根源是出现bean名称重复
原因:
1.两个bean名称重复,spring扫描无法创建bean对象(有时候会与引入的第三方的jar包中的bean名称重复);
2.target中有缓存导致,Maven项目clean下再编译