org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML doc...

本文介绍了一个关于Spring框架中出现的Bean定义冲突问题及其解决方法。冲突发生在两个不同包下的相同名称类之间,导致了Spring容器无法正确管理和实例化这些Bean。文章提供了具体的错误信息,并给出了重新命名Bean来解决这一问题的有效方案。

【报错】

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL [file:/F:/MyWorkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/marbled-cat/WEB-INF/classes/spring-servlet.xml]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'merchantController' for bean class [org.mcc.merchant.controller.MerchantController] conflicts with existing, non-compatible bean definition of same name and class [org.mcc.campus.manager.controller.MerchantController]
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:414)

 

【可能产生原因】

不同的package里有两个名字相同的类,只是类所在的目录不同。

 

【解决方法】

spring管理bean大概类似把bean实例化放到map中,它会以配置的id和name(如果配置的话)为key存放起来,

2个一样的肯定要成冲突,应该给他们换个名字就成啦

 

类似于

controller("systemHomeController")
controller("moduleHomeController")

  

转载于:https://www.cnblogs.com/frankielf0921/p/9276139.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值