Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [so.dian.dev.device.interfaces.IDeviceInfoSV] is defined: expected single matching bean but found 2: deviceInfoSVImpl,IDeviceInfoSV
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1126)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 19 more
首先說下我的工程結構:controller——>manager——>sv——>dao
可以看出上面的異常是因為mybatis的自動掃描掃到了sv層的接口,mybatis會拿這個sv接口與mapper去匹配,而mapper里配置的都是dao層的
<mapper namespace="so.dian.dev.dao.device.IDeviceInfoDAO">
所以當然找不到了。解決的辦法就是不讓他掃到sv層的接口,使用@MapperScan("so.dian.dev.dao") 這個注解
@SpringBootApplication
@PropertySource({"variables.properties","resource.local.properties"})
@MapperScan("so.dian.dev.dao")
@EnableCaching
public class Application extends SpringBootServletInitializer{
