为Maven pom提供外部参数,并在application.properties文件中替换相同的参数
我正在从事testNg项目,我需要为pom.xml提供外部参数,它应该在application.properties文件中被替换,该文件将在我的项目中进一步使用。为Maven pom提供外部参数,并在application.properties文件中替换相同的参数,maven,junit,testng,pom.xml,Maven,Junit,Testng,Pom.xml,我正在从事testNg项目,我需要为pom.xml提供外部参数,它应该在application.properties文件中被替换,该文件将在我的项目中进一步使用。 谁能列出我需要使用的步骤和插件。我已经解决了这个问题。我在pom.xml中添加了一个配置文件,并配置了属性替换 <profiles> <profile> <id>profile1</id> <properties>
谁能列出我需要使用的步骤和插件。我已经解决了这个问题。我在pom.xml中添加了一个配置文件,并配置了属性替换
<profiles>
<profile>
<id>profile1</id>
<properties>
<url>https://www.bing.com</url>
<search>bitcoin</search>
</properties>
</profile>
</profiles>
<build>
<testOutputDirectory>${basedir}/target/classes</testOutputDirectory>
<filters>
<filter>src/main/resources/runtime.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
要运行测试,请执行以下操作:
mvn test -Pprofile1 -Durl=https://www.google.com -Dsearch=Blockchain
url和搜索变量的值将在runtime.properties文件中替换为上述命令参数中给定的值
-Durl=https://www.google.com and
-Dsearch=Blockchain
应用程序.properties
是否已被筛选?然后,您可以使用-Dparameter=value
提供参数。默认情况下,它是禁用的。禁用了什么?将其过滤有什么问题?
-Durl=https://www.google.com and
-Dsearch=Blockchain