为了账号安全,请及时绑定邮箱和手机立即绑定

Java项目中,不同包下有重名的Java文件,启动的时候为什么会报错?

Java项目中,不同包下有重名的Java文件,启动的时候为什么会报错?

慕侠2389804 2018-08-29 13:25:32
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/classes/springContext.xml]; nested exception is java.lang.IllegalStateException: Annotation-specified bean name 'cardController' for bean class [com.qdzq.wlpt.controller.api.CardController] conflicts with existing, non-compatible bean definition of same name and class [com.qdzq.wlpt.controller.admin.CardController]不同包下的文件不是可以重名吗?
查看完整描述

2 回答

?
繁星淼淼

TA贡献1775条经验 获得超11个赞

你有2个CardController,自动注入后bean的id就冲突了,如果2个都想要,在spring文件里面配置2个bean,设置成不同的id,就不会冲突了,spring默认bean的id就是类名首字母小写

查看完整回答
反对 回复 2018-09-16
  • 2 回答
  • 0 关注
  • 1244 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信