zoukankan      html  css  js  c++  java
  • idea中Mapper接口无法自动注入,报"Invalid bound statement (not found) "异常

    首先声明Mapper接口时,could not autowire,是因为idea的拼写检查,并不影响执行
    Setting->Inspections->Spring->springCore->Code->Autowiring for Bean Class设置为nohighliting ,only fixed.即可
    接下来的说”Invalid bound statement “异常,不能找到Mapper接口的代理类
    1.检查了我的配置文件,没有问题
    2.我看网上很多人说因为Idea不能编译resources目录下的XML文件,然后target下的classes目录下不会生成XML文件,需要在maven项目的pom文件build下加入以下配置

    <build>
    <resources>
    <resource>
    <directory>src/main/java</directory>
    <includes>
    <include>**/*.properties</include>
    <include>**/*.xml</include>
    </includes>
    <filtering>false</filtering>
    </resource>
    <resource>
    <directory>src/main/resources</directory>
    <includes>
    <include>**/*.properties</include>
    <include>**/*.xml</include>
    </includes>
    <filtering>false</filtering>
    </resource>
    </resources>
    </build>

    可是我的target目下有XML等配置文件,所以不是这个问题,我使用的是IDEA 2017.2.6版本,我想idea应该新点的版本解决了这个问题.
    我们知道Mybaties中,Mapper接口和XML配置文件需要在一个目录下。
    3、最后我发现我的问题是:
    这里写图片描述 
    我的resources下的文件建立错误了。
    eclipse的resources下可以建立pacakge,但是Idea下不能,只能建立Directory,即目录.
    所以我之前新建com.ray.mybbs.mapper.test,这显然是一个文件夹的名称。
    正确的建立方式是com/ray/mybs/mapper/test,这样建立多级目录
    ---------------------
    作者:一个宋冬野
    来源:CSDN
    原文:https://blog.csdn.net/ray_jone/article/details/79371448
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    面向对象-类与实例化对象
    面向对象-面向对象与面向过程优缺点
    pyCharn文件模板变量
    安装pycrypto以及报错处理
    文件-读、写、追加已经文件操作
    文件-读取与编码检测
    运算-三元运算
    三方工具-sqlacodegen
    函数-生成器之斐波拉契数列
    python内存-fromkeys
  • 原文地址:https://www.cnblogs.com/qin-up/p/10103093.html
Copyright © 2011-2022 走看看