maven 自动部署war(项目)到tomcat

1.软件版本

apache-tomcat-7.0.55

apache-maven-3.2.2

eclipse-standard-luna-R-win32-x86_64


2.修改文件

2.1 tomcat  tomcat-users.xml

 增加如下用户 角色 manager-script

  • manager-script — Access to the tools-friendly plain text interface that is described in this document, and to the "Server Status" page.


  <role rolename="manager-script"/>
  <role rolename="manager-gui"/>
  <role rolename="admin-gui"/>
  <user username="admin" password="admin" roles="manager-script"/>

参考文档 

http://127.0.0.1:8080/docs/manager-howto.html#Configuring_Manager_Application_Access

2.2 maven setting.xml

servers 里添加

    <server>
      <id>tomcat7</id>
      <username>admin</username>
      <password>admin</password>
    </server>


2.3 项目 pom.xml

<plugin>
					<groupId>org.apache.tomcat.maven</groupId>
					<artifactId>tomcat7-maven-plugin</artifactId>
					<version>2.0-beta-1</version>
					<configuration>
						<url>http://localhost:8080/manager/text</url>
						<server>tomcat7</server>
						<username>admin</username>
						<password>admin</password>
					</configuration>
				</plugin>

注:此处的server 里面的tomcat7 要与上2.2maven 配置文件setting.xml 里server id 一致 


maven 命令:tomcat7:deploy

如下图

maven 自动部署war(项目)到tomcat

你可能感兴趣的:(maven 自动部署war(项目)到tomcat)