本文主要是介绍Annotation-specified bean name 'xxxController' for bean class conflicts with existing,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
错误信息
2020-01-07 09:27:08,906 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [spring-mvc.xml]
Offending resource: file [D:\apache-tomcat-7.0.54\webapps\jeemtg\WEB-INF\classes\spring-context.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [D:\apache-tomcat-7.0.54\webapps\jeemtg\WEB-INF\classes\spring-mvc.xml]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'townController' for bean class [com.jeeplus.modules.frontpage.TownController] conflicts with existing, non-compatible bean definition of same name and class [com.jeeplus.modules.declare.web.TownController]at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:266)at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:191)at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:176)at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:149)at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:103)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:510)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)at
一、确定大致方向,提取重点信息
找自己能看懂的内容
Annotation-specified bean name 'townController' for bean class [com.jeeplus.modules.frontpage.TownController] conflicts with existing, non-compatible bean definition of same name and class [com.jeeplus.modules.declare.web.TownController]
利用翻译软件翻译一下:为bean类[com.jeeplus.modules.frontpage.TownController]指定的注解bean名称“townController”与同名类[com.jeeplus.modules. declre .web. townController]的现有的、不兼容的bean定义冲突。即,存在两个townController,导致bean冲突。
二、发现问题根本
根据提示信息可得知,两个文件分别存在com.jeeplus.modules.frontpage.TownController和com.jeeplus.modules. declre .web. townController下,查看得知,果真如此(如下图所示)
三、解决错误
去重:更换其中一个TownController文件名
这篇关于Annotation-specified bean name 'xxxController' for bean class conflicts with existing的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!