因为将mapper.xml文件放在了java目录下,导致正常配置没法找到我的xml文件:

我的yml文件配置如下:
mybatis-plus:
mapper-locations: com/lingchao/mybatisplusdemo/mapper/*
报错如下:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.lingchao.mybatisplusdemo.dao.UserMapper.selectAll2
解决方案,在pom中加入一段配置:

<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>

由于将mapper.xml文件错误放置在java目录下,导致MybatisPlus在Idea中无法找到对应的XML文件,从而引发BindingException。在报错信息中指出bound statement (not found): com.lingchao.mybatisplusdemo.dao.UserMapper.selectAll2。解决此问题,需要在项目的pom.xml中添加特定配置。
766

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



