Mingyang.net:org.springframework.context.annotation.ConflictingBeanDefinitionException

org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name ‘configController‘ for bean class [net.mingyang.modules.system.ConfigController] conflicts with existing, non-compatible bean definition of same name and class [net.mingyang.cms.controller.ConfigController]
    org.springframework.context.annotation.ClassPathBeanDefinitionScanner.checkCandidate(ClassPathBeanDefinitionScanner.java:314)
    org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:253)
    org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:85)
    org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
    org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1424)
    org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1414)
    org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
    org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:141)
    org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
    org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    ... ...

问题的根源是我在两个不同的package里面定义两个ConfigController。默认的,Spring以类名作为Bean名,两个不同包里面的ConfigController就变成了相同的名字。

package net.mingyang.modules.system;

@Controller
@RequestMapping("/control/system/config")
public class ConfigController
{
    ......
}

//-----------------------------------------------------

package net.mingyang.cms.controller;

@Controller
@RequestMapping("/control/cms/config")
public class ConfigController
{
    ......
}

解决方法是为两个@Controller指定名字:

package net.mingyang.modules.system;

@Controller("/control/system/config")
@RequestMapping("/control/system/config")
public class ConfigController
{
    ......
}

//-----------------------------------------------------

package net.mingyang.cms.controller;

@Controller("/control/cms/config")
@RequestMapping("/control/cms/config")
public class ConfigController
{
    ......
}

Mingyang.net:org.springframework.context.annotation.ConflictingBeanDefinitionException

时间: 2024-10-12 11:15:34

Mingyang.net:org.springframework.context.annotation.ConflictingBeanDefinitionException的相关文章

Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser]

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class pa

Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext.xml]; nested exception is java.lang.IllegalStateException: Context

[org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on

<2015-4-10 下午02时55分35秒 CST> <Info> <Security> <BEA-090905> <Disabling the CryptoJ JCE Provider self-integrity check for better startup performance. To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerifica

错误:org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWeb

详细错误: 1 org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedSer

org.springframework.context.ApplicationContextAware使用理解

一.这个接口有什么用? 当一个类实现了这个接口(ApplicationContextAware)之后,这个类就可以方便获得ApplicationContext中的所有bean.换句话说,就是这个类可以直接获取spring配置文件中,所有有引用到的bean对象. 二.怎么用? 举个例子吧: 例如我有一个方法类AppUtil,这个方法类中需要使用到的ApplicationContext中的某个bean(companyService). 1.因为spring要建立属于自己的容器,就必须要加载自己的配置

问题 : lang.NoClassDefFoundError: org/springframework/core/annotation/AnnotatedElementUtils,的解决方法

今天在做junit 测试的时候  出现了一个问题,花了一段时间 才解决. java.lang.NoClassDefFoundError: org/springframework/core/annotation/AnnotatedElementUtils at org.springframework.test.util.MetaAnnotationUtils$AnnotationDescriptor.<init>(MetaAnnotationUtils.java:289) at org.spri

SpringCloud报错:Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

今天启动用eureka的服务消费者时,一直出现问题. SpringCloud报错: Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 解决方案: 网上的解决方案大多如下: 1.在main()方法的启动类的上方添加注解

IDEA启动tomcat报错:java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext、ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component

先看日志: 27-May-2019 17:07:29.838 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/9.0.0.M26 27-May-2019 17:07:29.844 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Aug 2 2017 2

spring Boot异步操作报错误: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type &#39;com.self.spring.springboot.Jeep&#39; available

我也是最近开始学习Spring Boot,在执行异步操作的时候总是汇报如下的错误: Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.self.spring.springboot.Jeep' available at org.springframework.beans.factory.sup