使用代码生成器生成的代码,编译时maven排除了.xml文件,导致mapper.xml找不到
这种BindingException就是因为生成的target文件中找不到对应的mapper.xml文件导致
解决办法:
1.在pom.xml文件中加入
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
2.在application.yml中加入mapper.xml的位置
mybatis-plus:
mapper-locations: classpath*:com/zyx/mall/mapper/**/*.xml