mybatis-plus xml路径的坑
mybatis-plus xml路径的坑
用mybatis-plus自定义sql xml时可能会报:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.*.mapper.UserMapper.findByUserName
解决方案有两个:
1.在pom.xml中添加配置:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
当然:还必须在 application.yml 中添加配置:
mybatis-plus:
mapper-locations: classpath*:com/*/mapper/xml/*Mapper.xml
可以完美解决 xml放在java包内的问题。
2.将mxl文件移入resources目录
当然还必须在 application.yml 中添加配置:
mybatis-plus:
mapper-locations: classpath*:/mapper/*.xml
以上就是mybatis-plus的坑