maven插件maven-resources-plugin的使用教程

章誉
2023-12-01

1、概念

maven中默认只能读取resources文件夹下的资源,如果要读取其他路径下的资源文件,那么就需要用到maven-resources-plugin这一插件

2、配置

(1)在maven配置文件pom.xml中导入插件

	  <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>2.6</version>
      </plugin>

(2)在build节点下面添加resource配置:

<resource>
		<!--从此目录下读取全部以.properties和.xml开头的文件-->
        <directory>src/main/resources/</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
        </includes>
</resource>
 <resource>
		 <!--从此目录下读取全部以.properties和.xml开头的文件-->
        <directory>src/main/java/</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
        </includes>
      </resource>
</resources>
 类似资料: