解决 org.springframework.context.annotation.ConflictingBeanDefinitionException

时间:2020-09-30 16:46:47   收藏:0   阅读:734

Java web 项目启动时报错

报错信息:

Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name ‘testService‘ for bean class [test.service.impl.TestServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [test.service.impl.TestService]

 

通过搜索定位到时以下代码片段造成的报错。

代码片段:

1.ITestService 的实现类代码:
@Service("testService")
public class TestServiceImpl implements ITestService {
......
}

2.在Controller中使用代码:
@Autowired
private ITestService testService;

 

解决方法:

代码 1 和 2 中的 testService 冲突了,修改1和2中任意的名字即可解决

原文:https://www.cnblogs.com/etangyushan/p/13753942.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!