报错:
nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 前缀包名.dao.AppMapper.list
原因:
网上有其他原因点,下面是这次遇到的原因:
maven打包时,没有将application.yml或properties、mapper的xml文件一起打包
解决方法:
在pom.xml的build节点中,添加下面配置即可:
<resources>
<!-- 打包java里mapper的xml文件 -->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<!-- 打包resource里的项目配置文件 -->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.yml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
本文解决了一个常见的Maven项目打包问题,即MyBatis的Mapper XML和配置文件未被包含,导致运行时报错。通过在pom.xml中添加资源文件配置,确保了XML和YML配置文件能正确打包进项目。
3106

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



