title: 解决Gradle、Maven项目build后没有mybatis的mapper.xml文件问题
date: 2019-05-31 21:09:59
categories:
- Java
tags: - 工具
Gradle
、Maven
都默认只把resources
目录当作资源目录,所以在编译时就不会把java
目录下的mapper.xml
文件编译到输出目录,所以需要在相关文件中修改默认资源目录。Maven
-
在
pom
文件中加入<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build>
-
在build.gradle文件中加入
sourceSets {
main {
resources.srcDirs = ['src/main/resources', 'src/main/java']
resources.includes = ['src/main/java/**.xml']
}
}
Gradle