zoukankan      html  css  js  c++  java
  • 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{
  • 相关阅读:
    DataSet调用Dispose必须吗
    Python基础
    windows下pip升级到8.1.1 及安装Selenium
    python文件编码说明 coding
    Response.End() VS Context.ApplicationInstance.CompleteRequest()
    Python练习正则
    Python2.7爬虫练习爬百度百科python词条
    未知错误:1000正在终止线程
    debug pin用
    读取文件
  • 原文地址:https://www.cnblogs.com/zhangXingSheng/p/7744995.html
Copyright © 2011-2022 走看看