错误信息
解决方法
maven 整合 mybatis 出现了错误
首先检查了这四种规范
遵循四种原则
- 命名空间 绑定此接口
- 接口的方法名 == User.xml 中 id 名
- 返回值类型 与 Mapper.xml文件中返回值类型要一致
- 方法的入参类型 与Mapper.xml中入参的类型要一致
再次检查了本地的文件
如图所示
在pom.xml 中添加如下代码
<!--
解决异常
org.apache.ibatis.binding.BindingException:
Invalid bound statement (not found): com.chao.mapper.PersonMapper.select
-->
<!-- maven项目中src源代码下的xml等资源文件编译进classes文件夹,
注意:如果没有这个,它会自动搜索resources下是否有mapper.xml文件,
如果没有就会报org.apache.ibatis.binding.BindingException:
Invalid bound statement (not found): com.chao.mapper.PersonMapper.select-->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<!--将resources目录下的配置文件编译进classes文件 -->
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
再次运行,运行成功