spring boot 集成mybatis報錯


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{


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM