我正在寻找一种在远程linux服务器的tomcat中部署使用eclipse开发的maven项目的方法。我知道您可以将其导出为.war文件,并将其转储到远程服务器的CATALINA_HOME/webapps文件夹中。但是,您必须首先将其导出为.war文件,然后通过SFTP或SCP将.war文件复制到远程服务器。我正在寻找一种方法,使用eclipse或/和配置一些maven设置(在pom.xml或settings.xml中),只需单击几次即可。有没有人知道怎么做?任何帮助都是非常感谢的。
发布于 2012-05-29 20:17:03
您要查找的工具名为
它主要做的是使用Tomcat管理器应用程序的API,您必须确保将该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 goal。(可以从命令行使用m2Eclipse插件从Eclipse.)
请参考插件的configuration和deployment页面了解更多详细信息。
发布于 2012-05-29 20:21:23
对于Tomcat、Jetty、Glassfish等不同的容器,最灵活的解决方案可能是Maven Cargo plugin。你可以找到an extensive list of examples on their homepage,所以不需要在这里再次粘贴。
发布于 2012-05-30 02:16:11
要远程部署应用程序,您需要在tomcat实例上配置tomcat deployer app。请注意,在tomcat6和7之间,admin用户的配置发生了一些微妙的变化。
一旦开始工作,Maven cargo插件就可以部署war文件,如下所示:
<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> 附加说明
https://stackoverflow.com/questions/10795863
复制相似问题