启动项目报错:
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type "省略......"
排查项目
1.实现类有添加注解
@Service
public class MainXXXServiceImpl{}
2.application.xml有添加bean配置
<bean id="MainXXXServiceImpl" class="com.xxx.service.impl.MainXXXServiceImpl" />
3.调用实现类的地方有引入
@Autowired
MainXXXServiceImpl mainXXXServiceImpl;
启动项目后,抛异常
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type '.......................'
available: expected single matching bean but found 2: MainXXXServiceImpl mainXXXServiceImpl
问题很显而易见了,bean不是唯一的,找到了两个,在在调用实现类引入的地方变量用了小写,而bean注册的地方又是大写,修改引入实现如下
@Autowired
MainXXXServiceImpl MainXXXServiceImpl;
运行正常,无异常信息