无论如何我可以在maven配置文件中传递参数。就像我想在特定端口上运行服务器,如果另外指定默认配置文件。就像当我运行mvn clean install -Pdeploy 4322时,应该将包部署到端口4322上运行的服务器,否则为4052。
是的,你可以传递环境变量,如:mvn ... -Pdeploy -DdeploymentPort=4322
然后访问配置文件中的变量,如下所示:
...
<port>${deploymentPort}</port>
...
您可以定义要在父pom.xml中使用的默认属性
<properties>
<crx.userId>admin</crx.userId>
<crx.password>admin</crx.password>
<crx.host>localhost</crx.host>
<crx.port>4502</crx.port>
</properties>
然后在父pom.xml或子项目的pom.xml中,您可以使用这些属性。
例:
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<targetURL>http://${crx.host}:${crx.port}/crx/packmgr/service.jsp</targetURL>
<userId>${crx.userId}</userId>
<password>${crx.password}</password>
</configuration>
</plugin>
然后在你的maven命令中使用-D[property name] = [value]
覆盖默认值。