[英]Deploying an eclipse maven project in a remote linux server's tomcat
我正在尋找一種在遠程Linux服務器的tomcat中部署使用eclipse開發的maven項目的方法。 我知道您可以將其導出為.war文件並將其轉儲到遠程服務器的CATALINA_HOME / webapps文件夾中。 但是為此,您必須首先將其導出到.war文件,然后通過SFTP或SCP將.war文件復制到遠程服務器。 我正在尋找一種使用Eclipse或/並配置一些Maven設置(在pom.xml或settings.xml中)的方法,只需單擊幾下即可。 有誰知道如何做到這一點? 任何幫助都非常感謝。
您正在尋找的工具稱為Tomcat Maven插件
它的基本作用是使用Tomcat管理器應用程序的API,您必須確保已將其部署在所使用的Tomcat實例上。 默認情況下,Tomcat管理器在以下位置可用:
http://ip_of_your_linux_server:8080/manager/html
如果不是,請使用以下命令進行安裝:
sudo apt-get install tomcat6-admin
您可以按如下方式配置Tomcat實例的位置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://www.mydomain.com:1234/mymanager</url>
</configuration>
</plugin>
然后運行maven mvn tomcat:deploy目標。 (從Eclipse的命令行使用m2Eclipse插件 。)
要遠程部署應用程序,您需要在tomcat實例上配置tomcat部署程序 。 請注意,在tomcat 6和tomcat 7之間,管理員用戶的配置進行了一些細微的更改。
一旦運行正常,Maven貨運插件可以如下部署戰爭文件:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>tomcat-deploy</id>
<phase>package</phase>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.uri>${tomcat.manager.url}</cargo.remote.uri>
<cargo.remote.username>${tomcat.manager.user}</cargo.remote.username>
<cargo.remote.password>${tomcat.manager.pass}</cargo.remote.password>
</properties>
</configuration>
<deployer>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<properties>
<context>${project.artifactId}</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
補充筆記
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.