spring boot 使用mybatis-plus问题一
作者:互联网
第一次写博客,目的有两个:首先是防止下次碰到类似的问题方便查找;其次是希望可以帮到遇到同样问题的小伙伴
一、在mybatis-plus的情况下 需要使用动态sql的情形,此时需要创建对应mapper 的实现类 xxMapper.xml
但是这个文件的位置有两种选择性
第一种是放在java包下,第二种选择是 放在resources包下 两种不同的方法 需要通过不同的配置 来将mapper.java 和mapper.xml绑定
- 当将mapper.xml放在java包下时 (一般和mapper.java同级包下),此时需要在pom.xml中进行以下配置方可进行绑定
<resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource>
</resources>
- 当将mapper.xml放在resources 类路径下时,一般放在新建包mapper下,此时需要在application.yml中配置进行绑定
mybatis-plus: mapper-locations: classpath*:/mapper/*Mapper.xml
注意:classpath*:/mapper/*Mapper.xml 中不能有空格;mapper-locations:冒号后面要有空格(如果配置文件是yml格式的话)
标签:xml,mapper,java,包下,spring,boot,plus,mybatis 来源: https://www.cnblogs.com/neal-blog/p/16102616.html