Use an alternative Maven Profile during test phase

旧巷老猫 提交于 2019-12-03 08:43:40

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

Not sure if this can help you at all but you can specify alternative resource files in the /src/test/resources folder which override the ones in /src/main/resources when running tests only.

I define an alternative placeholders.properties file here to specify another db connection to be used by the test phase.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!