解决项目编译的target目录下丢失xml文件

2022-08-11 12:39:32

由于Maven在默认的情况下针对我们的Java目录下的非Java文件不会执行编译操作,所以会在classes目录下丢失Mapper.xml文件

  • 解决方法
  1. 在pom.xml文件的目录中添加
<!--项目打包会将java目录中的*.xml文件进行打包--><resources><resource><directory>src/main/java</directory><includes><include>**/*.xml</include></includes><!--默认情况下是true 现在修改为false 就不会过滤掉这个xml文件了--><filtering>false</filtering></resource></resources>
  • 这样重新编译项目后在target目录下就不会过滤掉xml文件了
  • 但是这样还不行,我们还需要让运行环境能够找到这个xml文件
  1. 需要在配置文件中配置一下mybatis-plus
# mybatis-plusmybatis-plus:configuration:# sql日志log-impl: org.apache.ibatis.logging.stdout.StdOutImplmapper-locations: classpath:com/zb/paymentdemo/mapper/xml/*.xml
  • 作者:z啵唧啵唧
  • 原文链接:https://blog.csdn.net/weixin_45809829/article/details/125176655
    更新时间:2022-08-11 12:39:32