最近在撸项目的时候发现一个问题,在使用mybatis-plus的时候,需要有一处地方用到sql语句,所以呢,我在java目录下写了xml文件
在xml文件中编写语句,运行后出现无法找到的结果,说明并没有打包进去了
遇到这种情况,有两种做法:
1、把xml文件放到resources中
2、pom文件进行如下配置
<build>
<!--项目打包时会讲java目录中的*.xml文件也进行打包-->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
另外在application.yml
文件中进行配置,当然,路径根据实际而定
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:com/zeny/edu/eduservice/mapper/xml/*.xml
终于加载进来了