Mapped Statements collection does not contain value for

深藏阁楼爱情的钟 2022-07-08 16:57 243阅读 0赞

SSM碰到这个问题,可能情况有这几种:

1、mapper.xml中没有加入namespace
2、mapper.xml中的方法和接口mapper的方法不对应
3、mapper.xml没有加入到mybatis-config.xml中(即总的配置文件),例外:配置了mapper文件的包路径的除外
4、mapper.xml文件名和所写的mapper名称不相同。
5、mapper包中的mapper.xml没有编译到targger中。

看了一下前面四种都是没有错的于是想到maven的配置文件可能有问题,
因为我的配置文件全部都会放在target文件目录下,这个消费者没有配置所以出错,于是加上如下代码(每个人的情况不一样,根据实际情况而定)

  1. <resources>
  2. <resource>
  3. <targetPath>${project.build.directory}/classes</targetPath>
  4. <directory>src/main/resources</directory>
  5. <filtering>true</filtering>
  6. <includes>
  7. <include>**/*.xml</include>
  8. <include>**/*.properties</include>
  9. </includes>
  10. </resource>
  11. </resources>

问题就解决了

发表评论

表情:
评论列表 (有 0 条评论,243人围观)

还没有评论,来说两句吧...

相关阅读