maven-resource-plugin

背景

有个项目在测试环境和线上环境需要包含不同的配置文件, 这就需要结合maven的profile和resource插件配置来解决了。

解决办法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

<filters>
<filter>src/main/filters/${profileActive}.properties</filter>
</filters>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>test/</exclude>
<exclude>production/</exclude>
</excludes>
</resource>
</resources>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}/</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/${profileActive}</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
文章目录
  1. 1. 背景
  2. 2. 解决办法
|