我们的应用由多个活动配置文件(例如A1、A2、A3、A5...)组成,这些配置文件在profiles.xml文件中分别定义。Maven 3希望将所有配置文件信息存储在pom.xml文件本身中。
我应该如何在pom.xml文件中指定活动配置文件列表,以避免在命令行中指定它们(例如mvn -PA1、A2、A3、A5)?
我应该如何在pom.xml文件中指定活动配置文件列表,以避免在命令行中指定它们(例如mvn -PA1、A2、A3、A5)?
这个代码是否可以解决问题:
<profiles>
<profile>
<id>profile-1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
...
</profile>
</profiles>
翻译自这里.
除了@javamonkey79的回答之外,您还可以使用settings.xml。其中包含配置文件和激活的部分。请参考以下示例:
<profiles>
<profile>
<id>hudson-simulate</id>
<properties>
<gituser>username</gituser>
<gitpassword>secret</gitpassword>
</properties>
</profile>
<profile>
<id>other-profile</id>
<properties>
<proerty1>username</property1>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>hudson-simulate</activeProfile>
<activeProfile>other-profile</activeProfile>
</activeProfiles>