您的位置:首页 > 移动开发

Mapped Statements collection does not contain value for

2016-10-11 18:41 429 查看
Mapped Statements collection does not contain value for后面是什么类什么方法之类的: 
错误原因有几种: 
1、mapper.xml中没有加入namespace 
2、mapper.xml中的方法和接口mapper的方法不对应 
3、mapper.xml没有加入到mybatis-config.xml中(即总的配置文件),例外:配置了mapper文件的包路径的除外 
4、mapper.xml文件名和所写的mapper名称不相同。

我遇到的问题是用maven管理mybatis项目。报Mapped Statements collection does not
contain value for的错误,找了半天原因,发现部署后没有Mapper.xml文件,因为.xml文件在java目录中而不是resources目录下,所以没有被认为是资源文件而被部署。在pom.xml中配置一下

<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
</resource>
<resource> <!-- 配置需要被替换的资源文件路径 -->
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>

红色字体是针对本次问题起作用的地方。当然,最好都配置上。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐