我们的政策是只构建 1 个可部署的 jar。所有特定于环境的配置都是分开的,我们一次将它们全部构建在一起。所以在我们当前的 Ant 进程下,我们为每个环境都有一个属性文件,循环它们,并为每个环境创建一组配置文件。
在我当前的 POM XML 中,我只能构建在命令行中提供的一个配置文件。是否可以通过Maven实现?
以下是 POM.xml 的一些相关部分
<!-- Define profiles here and make DEV as default profile -->
<profiles>
<!-- dev Profile -->
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- qa Profile -->
<profile>
<id>qa</id>
<properties>
<env>qa</env>
</properties>
</profile>
<!-- prod Profile -->
<profile>
<id>prod</id>
<properties>
<env>prod</env>
</properties>
</profile>
</profiles>
...
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<filters>
<filter>env/${env}.properties</filter>
</filters>
<outputDirectory>${project.build.directory}/config/${env}
</outputDirectory>
<resources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/config/default
</directory>
<includes>
<include>*.xml</include>
<include>*.properties</include>
</includes>
</resource>
......
谢谢, 普拉布约特