Mybatis:invalid bound statement (not found)解决办法
在springboot框架web项目工程起步的时候,
往往用最简单的方式:mybatis逆向工程,配置GeneratorMapper.xml
,连接数据库
从数据库中将数据自动装配好pojo到工程中。
但是当测试的时候总会显500?!
WTF
各种调试,各种找Bug,网上大多数人说是mapper配置文件路径问题,但我的没错啊
springboot启动类中也注解了
@MapperScan(basePackages = "com.yxyl.springboot.mapper"),
最后才发现这种说法:
原来是需要在pom.xml文件中配置resource,不然mapper.xml文件就会被漏掉!
pom.xml的标签下配置
500不见~
基础不牢,地动山摇…
<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>