错误提示:
严重: Servlet.service() for servlet [springmvcServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.xxx.mapper.EmployeeMapper.selectByPrimaryKey] with root cause
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.xxx.mapper.EmployeeMapper.selectByPrimaryKey
问题所在:mybatis中的xxxMapper.xml 文件因为在src/main/java无法读取;需在pom.xml文件中添加如下代码
注: 只配置单个src/main/java 或者 src/main/resources,将报错:No mapping found for HTTP request with URI
代码如下:
<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>
本文解决了MyBatis中因无法找到指定Mapper而导致的应用错误问题。通过在pom.xml文件中正确配置资源路径,确保了MyBatis可以读取位于src/main/java目录下的xxxMapper.xml文件。
4897

被折叠的 条评论
为什么被折叠?



