Annotation-specified bean name 'xxxController' for bean class conflicts with existing
程序员文章站
2022-07-14 21:26:05
...
错误信息
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文件名
上一篇: 存储过程 游标