常规的问题都检查了,还是报错。
用mp代码生成器的目录结构如下:
xml文件没有放在resources路径下
这样会导致xml文件不在target目录下,解决的方式是在pom.xml文件中加入:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.png</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
这样target目录下有xml文件了,仍然报错。
还需要修改配置文件,这个地方排查了好久!!!
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
mapper-locations: classpath:com/atguigu/*/mapper/xml/*.xml
解决Mybatis 报错Invalid bound statement (not found)
当xml在resources中mapper对应路径时,不用修改mapper-locations
mybatis mapper-locations作用