Maven发布项目到Tomcat7中

来源:互联网 发布:无尽的传说2 mac 编辑:程序博客网 时间:2024/05/29 08:34

1.记得要在系统变量里添加tomcat的路劲,通常我们会用myeclipse直接启动tomcat,所以不要忽略了

2.添加tomcat的管理用户

TOMCAT_HOME/conf/tomcat-users.xmlfile 

under thetomcat-users root element. This will
create a user with the name admin and the password password, having the
manager-gui and manager-script roles.

<role rolename="manager-gui"/><role rolename="manager-script"/><user username="admin" password="password" roles="managergui,manager-script"/>
3.Maven配置远程tomcat

USER_HOME/.m2/settings.xml(或者..\apache-maven-3.0.4\conf\settings.xml)

Now, we need to configure Maven to talk to the remote Tomcat server.
Add the following configuration to USER_HOME/.m2/settings.xml under
the servers element, as follows:
<server><id>apache-tomcat</id><username>admin</username><password>password</password></server>
4.pom.xml添加tomcat插件

<build><finalName>my-webapp</finalName><plugins><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>apache-tomcat</server><path>/my-webapp</path></configuration></plugin></plugins></build>
5.
在项目下发布,重新发布,撤销发布
$ mvn clean install tomcat7:deploy
$ mvn clean install tomcat7:redeploy
$ mvn clean install tomcat7:undeploy














0 0