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{