[英]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.