【发布时间】:2011-07-01 14:46:23
【问题描述】:
我使用 tomcat-maven-plugin 将我的战争部署到服务器。我要做的就是在我的 pom.xml 中像这样配置它:
<configuration>
...
<url>http://localhost/manager</url>
<username>admin</username>
<password>admin</password>
...
</configuration>
但是我显然想将此设置保留在不同的位置,因为我在我的计算机上工作,但是还有一个暂存服务器和一个实时服务器,其中服务器的设置不同。
所以让我们使用.m2/settings.xml:
<servers>
<server>
<id>local_tomcat</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
现在更改 pom.xml:
<configuration>
<server>local_tomcat</server>
</configuration>
但是将服务器的 URL 放在哪里呢?在 server 标签下的 settings.xml 中没有那个地方!也许是这样?
<profiles>
<profile>
<id>tomcat-config</id>
<properties>
<tomcat.url>http://localhost/manager</tomcat.url>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>tomcat-config</activeProfile>
</activeProfiles>
..并使用 ${tomcat.url} 属性。
但问题是,为什么要在settings.xml 中使用服务器标签呢?为什么不使用用户名和密码的属性呢?还是在设置 URL 中也有 URL 的位置,所以我不必使用属性?
【问题讨论】: