报错信息如下:
网上说了很多方法,结合自身的经验,做了下汇总
- mapper类与xml中的路径要一致(Generator生成可以忽略)
- Application中配置@MapperScan(“xx.xx.mapper”),这里注意一定要指定到mapper目录下,多路径配置则是@MapperScan({“a.mapper”,“b.mapper”})
- 检查properties或yml配置中的mybatis-plus.mapper-locations是否与编译好后的resources中xml的路径一致
- 检查gradle或maven中配置,详见下方
gradle配置
processResources {
from('src/main/java') {
include '**/*.xml'
}
}
sourceSets.main.resources.srcDirs = ["src/main/java", "src/main/resources"]
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>