3、maven3.2.3+myEclipse8.6自动部署war包到tomcat

1、在tomcat安装目录下找到tomcat-users.xml文件。该文件路径为【tomcat安装根目录】/conf/,修改文件内容,增加下列内容:

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

2、项目的pom.xml文件中,删除一下内容:

  <build>
    <finalName>testDemo</finalName>
  </build>

3、项目的pom.xml文件中,增加下列<plugin></plugin>中内容:

<properties>
        <finalName>testDemo</finalName>
  </properties>
  <build>
	<plugins>
		<plugin>
			<groupId>org.codehaus.mojo</groupId>
			<artifactId>tomcat-maven-plugin</artifactId>
			<configuration>
			<url>http://localhost:8080/manager</url>
			<username>tomcat</username>
			<password>123456</password>
			<path>/${finalName}</path>
			</configuration>
		</plugin>
	</plugins>
  </build>

其中<url>http://localhost:8080/manager</url>  ,8080是tomcat的端口号,manager是tomcat的rolename。

username和password就是tomcat中配置的username和password。

如果使用的是Tomcat 7,需要修改pom.xml中部署的url地址,将<url>http://localhost:8080/manager</url>改<url>http://localhost:8080/manager/text</url>

在pom.xml的<properties>标签中,<finalName>定义war包的名字。假如只写成<path>/</path>,则部署的war包名字为ROOT.war。

4、项目右键:Run As ,选择:Run  Configurations...

wKioL1RLTRXhq_xCAAPBMabgrPU972.jpg


运行maven命令:

tomcat:redeploy

就是要在Goals填入:tomcat:redeploy

->Run

wKiom1RLTMPA1-uLAALXSfibrEc689.jpg

wKioL1RLTjPgodJtAAGfFv36ttQ218.jpg


本文出自 “江山如画待赢归” 博客,谢绝转载!

你可能感兴趣的:(tomcat,自动部署,Myeclipse8.6,Maven3.2.3)