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{
  • 相关阅读:
    name mangling
    Haskell: What is Weak Head Normal Form
    取模运算和取余运算的区别
    a common method to rotate the image
    代码静态分析工具
    LeeCode-Single Number III
    七夕这天
    mysql TO_DAYS()
    (转)剖析Linux文件编码的查看及修改
    docker
  • 原文地址:https://www.cnblogs.com/zhangXingSheng/p/7744995.html
Copyright © 2011-2022 走看看