【发布时间】:2017-07-22 19:19:21
【问题描述】:
我试图在我的项目 pom.xml 文件中使用配置文件来控制我的 war 文件到特定服务器的部署。例如,我有一个本地配置文件和一个开发服务器配置文件。这是我设置个人资料的方式
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>target</name>
<value>local</value>
</property>
</activation>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://10.16.21.60:8080/manager/text</url>
<server>localTomcat</server>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>dev</id>
<activation>
<property>
<name>target</name>
<value>dev</value>
</property>
</activation>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://devserverurl:8080/manager/text</url>
<server>devTomcat</server>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</profile>
我在打电话
mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy
当我尝试这个时,我可以看到不是尝试连接到我的配置中提供的 IP 地址10.16.21.60,而是尝试连接到localhost。我在本地 settings.xml 文件中使用用户名和密码同时定义了 devTomcat 和 localTomcat。
如果我随后添加 -X 选项以获取更多信息,我可以在插件的调试输出中看到(强调添加)
我的配置设置似乎没有得到遵守!我认为这可行的方式是,由于local 配置文件已激活,它将使用该配置。
我也尝试过简单地在我的<build> 部分定义插件,没有配置文件,效果相同。它总是尝试连接到 http://localhost:8080 而不进行身份验证。
可能值得注意的是,我也在为这个项目使用gwt-maven-plugin,我不知道这是否会干扰 tomcat 插件配置。
【问题讨论】:
标签: maven tomcat gwt maven-tomcat-plugin gwt-maven-plugin