maven+tomcat热部署

时间:2023-03-08 20:30:44

1.首先修改tomcat安装目录下的conf文件夹中的tomcat-user.xml文件
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <user username="tomcat" password="tomcat" roles="manager-gui,manager-script"/>

maven+tomcat热部署

2.重启tomcat后,在tomcat首页点击manager,输入上面配置的用户名密码后,进入到如下页面,表示配置的没有问题。

maven+tomcat热部署

3.  pom文件中添加如下插件

maven+tomcat热部署

<plugin>
  <groupId>org.apache.tomcat.maven</groupId>
  <artifactId>tomcat7-maven-plugin</artifactId>
  <version>2.2</version>
  <configuration>
  <port>8181</port>
  <path>/appName</path>
  <url>http://ip:端口/manager/text</url>
  <username>tomcat</username>
  <password>tomcat</password>
  </configuration>
</plugin>

4.使用maven命令进行部署。
tomcat7:deploy(第一次)
tomcat7:redeploy(重新部署)
部署工程跳过测试:clean tomcat7:redeploy -DskipTests

maven+tomcat热部署

热部署成功