2014-03-27 95 views
1

在不同機器間,兩個Tomcat服務器web應用程序,我想我的部署web應用程序都在Windows 7的Tomcat和Unix的Tomcat 7接二連三或在同一時間,如果可能的話。目前,我能夠使用Tomcat,Maven的插件,並呼籲mvn tomcat7:redeploy成功部署web應用程序我在 Tomcat的視窗。但限制是,我不得不改變我的聚甲醛,這樣,如果我想 部署在Unix上的Web應用程序,這是非常痛苦的它指向的Unix Tomcat的。關於如何實現這一點的任何想法?請指導。部署不同的操作系統

的pom.xml

<plugin> 
    <groupId>org.apache.tomcat.maven</groupId> 
    <artifactId>tomcat7-maven-plugin</artifactId> 
    <version>2.2</version> 
    <configuration> 
     <url>http://localhost:8080/manager/text</url> 
     <server>win-tomcat</server> 
     <path>/${project.artifactId}</path> 
    </configuration> 
</plugin> 

.m2目錄/ settings.xml中

<settings> 
    <servers> 
     <server> 
      <id>unix-tomcat</id> 
      <username>manager</username> 
      <password>manager</password> 
     </server> 
     <server> 
      <id>win-tomcat</id> 
      <username>manager</username> 
      <password>manager</password> 
     </server> 
    </servers> 
</settings> 

回答

2

您可以創建兩個單獨的build profiles一個對每一臺機器做出來,對陣雙方的個人資料一個執行構建陸續

+0

這就是我是這麼認爲的開始。雖然這是我從未嘗試過的,但會檢查出來。感謝您的指導。 – user2325154

0

如果你不希望訴諸配置文件,但部署到無論是在一個去,你可以這樣定義於是兩個<execution> S:

<plugin> 
    <groupId>org.apache.tomcat.maven</groupId> 
    <artifactId>tomcat7-maven-plugin</artifactId> 
    <version>2.2</version> 
    <executions> 
    <execution> 
     <id>deploy-windows</id> 
     <configuration> 
     <url>http://localhost:8080/manager/text</url> 
     <server>win-tomcat</server> 
     <path>/${project.artifactId}</path> 
     </configuration> 
    </execution> 
    <execution> 
     <id>deploy-unix</id> 
     <configuration> 
     <url>http://unix:8080/manager/text</url> 
     <server>unix-tomcat</server> 
     <path>/${project.artifactId}</path> 
     </configuration> 
    </execution> 
    </executions> 
</plugin> 
+0

太好了。我會試試這個。 – user2325154

+0

沒有工作!當我使用上述解決方案時執行'mvn tomcat7:redeploy'命令時獲取401(未授權的例外)。我測試了部署到Unix tomcat服務器,以確保戰爭像Windows那樣上傳,並且沒有任何問題。 – user2325154

+0

只是爲了澄清,你的意思是,如果你只有1'<配置>'在插件它同時適用於贏/ Unix的?但是,如果您將與我的示例中''塊中完全相同的配置放置在此塊中,則會失敗?無論是Win/Unix還是隻針對一個都會失敗? –

相關問題