我正在开发一些开源项目,不希望将生产服务器的 URL 与源代码一起保存在公共存储库中,但同时我希望有机会使用 tomcat-maven-plugin 进行部署。
我试图将服务器 url 从 pom.xml 移动到 settings.xml,但没有成功。您能否给我一个提示,将 url 排除在 pom.xml 之外的最佳方法是什么?
非常感谢您。
这是我的配置:settings.xml
<settings>
<servers>
<server>
<id>prod</id>
<username>deployer</username>
<password>********</password>
</server>
</servers>
</settings>
pom.xml(在项目中)
<project>
...
<profiles>
<profile>
<id>prod</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<server>prod</server>
<url>http://host:XXXX/manager/text</url>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
更新:是的,有机会将其保存在 .properties-files 中,但是:
- 将服务器配置保存在几个地方有点奇怪,即~/.m2/settings.xml、application.properties、pom.xml。只要用户名和密码能够存储在 settings.xml 中,最好将服务器 URL 也保留在那里。
- 实际上我无法让它工作,所以我一直在以这种方式工作作为解决方法......
更新 2:刚刚发现,为什么读取属性的方法对我不起作用。我用了:
mvn tomcat7:redeploy
部署应用程序,并且properties-maven-plugin没有在tomcat7-maven-plugin配置的占位符中注入属性。由于部署阶段,我更改了tomcat7-maven-plugin执行后,属性注入通过调用正常工作:
mvn clean deploy
但是,我想知道,是否可以将服务器 URL 保留在settings.xml 中?