1
我正在嘗試使用我的項目pom.xml文件中的配置文件來控制我的戰爭文件到特定服務器的部署。舉個例子,我有一個本地配置文件和一個開發服務器配置文件。這裏是我有我的配置文件設置Maven Tomcat部署插件與配置文件
<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
當我嘗試這一點,我可以看到的是,而不是試圖連接到我的配置10.16.21.60
提供的IP地址,而是試圖連接到localhost
。我使用用戶名和密碼在本地settings.xml
文件中定義了devTomcat
和localTomcat
。
如果我再加入-X
選項更多的信息,我可以在調試輸出插件看到(加上強調)
[DEBUG] Configuring mojo org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy from plugin realm ClassRealm[plugin>org.apache.tomcat.maven:tomcat7-maven-plugin:2.2, parent: sun.misc.Launcher$AppClassLoader[email protected]] [DEBUG] Configuring mojo 'org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy' with basic configurator --> [DEBUG] (f) charset = ISO-8859-1 [DEBUG] (f) contextFile = .... [DEBUG] (f) ignorePackaging = false [DEBUG] (f) mode = war [DEBUG] (f) packaging = war [DEBUG] (f) path = ... [DEBUG] (f) update = false [DEBUG] (f) url = http://localhost:8080/manager/text [DEBUG] (f) version = 2.2 [DEBUG] (f) warFile = ... [DEBUG] (f) settings = [email protected] [DEBUG] -- end configuration -- [INFO] Deploying war to http://localhost:8080/... [DEBUG] No server specified for authentication - using defaults
它不會出現我的配置設置正在堅持!我認爲這將起作用的方式是,因爲激活了local
配置文件,它將使用該配置。
我也嘗試過簡單地在我的<build>
部分定義插件,但沒有配置文件,效果相同。它始終嘗試連接到http://localhost:8080
而無需身份驗證。
可能值得注意的是,我也在爲這個項目使用gwt-maven-plugin
,我不知道這是否會干擾tomcat插件配置。