3806850 发表于 2013-2-4 15:46:27

maven 实现tomcat的远程部署

要将windows环境下开发的java项目部署到linux服务器上,用maven来做是很方便的。具体的步骤如下:
linux服务器上的tomcat配置有管理权限的用户:conf\tomcat-users.xml

Java代码

<?xml version='1.0' encoding='utf-8'?><tomcat-users><role rolename="manager"/><user username="marshal" password="password" roles="manager"/></tomcat-users>

在pom文件的tomcat插件中添加:
Java代码

<plugin><groupId>org.codehaus.mojo</groupId><artifactId>tomcat-maven-plugin</artifactId><configuration><url>http://localhost:8080/manager</url><server>myserver</server><path>/mycontext</path></configuration></plugin>

在.m2/settings.xml文件中增加:
Java代码


<settings xmlns="http://maven.apache.org/POM/4.0.0"      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/settings-1.0.0.xsd">      <servers>                <server>                        <id>myserver</id>                        <username>marshal</username>                        <password>password</password>                </server>      </servers></settings>
相关命令

运行打包部署:
Java代码
mvn tomcat:deploy

mvn tomcat:deploy

撤销部署:
Java代码
mvn tomcat:undeploy

mvn tomcat:undeploy

启动web应用:
Java代码
mvn tomcat:start

mvn tomcat:start

停止web应用:
Java代码
mvn tomcat:stop

mvn tomcat:stop

重新部署:
Java代码
mvn tomcat:redeploy

mvn tomcat:redeploy

部署展开的文件:
Java代码
mvn war:exploded tomcat:exploded

http://jiessiedyh.iteye.com/blog/471066
页: [1]
查看完整版本: maven 实现tomcat的远程部署