解决:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

298次阅读
没有评论

共计 572 个字符,预计需要花费 2 分钟才能阅读完成。

  • 在用 maven 配置 mybatis 环境时出现此 BindingExceptiony 异常,发现在 classes 文件下没有 mapper 配置文件,应该是 maven 项目没有扫描到 mapper 包下的 xml 文件,在 pom.xml 中加入一下代码可以解决:
 <build>
    <resources>
      <!-- maven 项目中 src 源代码下的 xml 等资源文件编译进 classes 文件夹,注意:如果没有这个,它会自动搜索 resources 下是否有 mapper.xml 文件,如果没有就会报 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.pet.mapper.PetMapper.selectByPrimaryKey-->
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </resource>

      <!-- 将 resources 目录下的配置文件编译进 classes 文件  -->
      <resource>
            <directory>src/main/resources</directory>
      </resource>
    </resources>
  </build>
正文完
 
alecctv
版权声明:本站原创文章,由 alecctv 2019-08-24发表,共计572字。
转载说明:除特殊说明外本站文章皆由ooly.cc发布,转载请注明出处。
评论(没有评论)
验证码