且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在测试阶段使用替代的Maven配置文件

更新时间:2021-12-15 00:45:44

我不确定这是否正是您要的,但是您可以执行以下操作为您的Maven项目设置多个过滤器.

I'm not sure if this is exactly what you are asking for, but you can do the following to setup multiple filters for your Maven project.

<filters>
  <filter>/your/path/filter-${env}.properties</filter>
</filters>

通过这种方式,您可以使用以下方式设置多个配置文件:

This way you can setup multiple profiles using:

<profiles>
  <profile>
    <id>local</id>
    <properties>
      <env>local</env>
    </properties>
  </profile>
  <profile>
    <id>test</id>
    <properties>
      <env>test</env>
    </properties>
  </profile>
</profiles>

然后可以使用以下相关属性文件运行构建:

You can then run the build with the relevant property file using:

mvn -P <profile id>

这将需要在以下位置包含属性文件:

This would require having property files located at:

/your/path/filter-local.properties
/your/path/filter-test.properties