zoukankan      html  css  js  c++  java
  • 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题

    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题

    即在mybatis中dao接口与mapper配置文件在做映射绑定的时候出现问题

    简单说,就是接口与xml要么是找不到,要么是找到了却匹配不到

     1 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.youxiu.edu.mapper.UserMapper.findUserById
     2     at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:223)
     3     at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48)
     4     at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59)
     5     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
     6     at com.sun.proxy.$Proxy18.findUserById(Unknown Source)
    

    在生成的target内可以发现没有mapper.xml,解决方法是在Dao的pom内配置mybatis-plus(只有mybatis.mapper-locations不起作用)

    如图:

    代码:

     1 <plugin>
     2                     <artifactId>maven-resources-plugin</artifactId>
     3                     <version>3.0.2</version>
     4                     <executions>
     5                         <execution>
     6                             <id>copy-xmls</id>
     7                             <phase>process-sources</phase>
     8                             <goals>
     9                                 <goal>copy-resources</goal>
    10                             </goals>
    11                             <configuration>
    12                                 <outputDirectory>${basedir}/target/classes</outputDirectory>
    13                                 <resources>
    14                                     <resource>
    15                                         <directory>${basedir}/src/main/java</directory>
    16                                         <includes>
    17                                             <include>**/*.xml</include>
    18                                         </includes>
    19                                     </resource>
    20                                 </resources>
    21                             </configuration>
    22                         </execution>
    23                     </executions>
    24                 </plugin>

    如果以上方法解决不了,可以尝试在pom中添加如下代码:

    1 <resources>
    2       <resource>
    3           <directory>src/main/java</directory>
    4           <includes>
    5               <include>**/*.xml</include>
    6           </includes>
    7       </resource>
    8 </resources>
  • 相关阅读:
    HTML5之标签
    Linux常用命令(二十四)
    Linux常用命令(二十三)
    Python 定位excel表格的最后一个单元格的位置
    tornado学习
    Linux一些基础命令
    用python打造自己的SDK--使用setuptools打包安装
    Centos开放指定端口命令
    python sqlalchemy基本使用
    python rpc
  • 原文地址:https://www.cnblogs.com/lkylin/p/12784536.html
Copyright © 2011-2022 走看看