报错信息:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.pet.mapper.UserMapper.queryUser
错误原因:*Mapper.xml没有自动复制到class输出目录的mapper类包下
解决方法:
用maven或者IDEA中自动扫描了resources目录下的文件,无法扫描*Mapper.xml文件,同时无法将配置文件加载到classes目录下解决方案:
在pom.xml中加入如下配置:
<build >
<resources>
<!-- maven项目中src源代码下的xml等资源文件编译进classes文件夹,
注意:如果没有这个,它会自动搜索resources下是否有mapper.xml文件,
如果没有就会报org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.pet.mapper.UserMapper.queryUser-->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<!--将resources目录下的配置文件编译进classes文件 -->
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>