前提:Tomcat要启动才能热部署
第一步:在Tomcat的conf下修改tomcat-users.xml配置文件,配置用户、密码和权限
加上
<role rolename="manager-gui" />
<role rolename="manager-script" />
<user username="tomcat" password="tomcat" roles="manager-gui, manager-script"/>
重启Tomcat。
第二步:在pom文件中配置tomcat插件
url中前面是IP加端口,后面是固定的(这是Tomcat7版本的)如果是Tomcat6,好像是没有后面的text
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<port>8082</port>
<path>/</path>
<!-- 系统热部署配置 -->
<url>http://192.168.226.143:8080/manager/text</url>
<username>tomcat</username>
<password>tomcat</password>
</configuration>
</plugin>
</plugins>
</build>
第三步:把maven工程部署到Tomcat中,跳过测试,重新部署(反正就这个命令好使,别的都报一堆错误)
clean tomcat7:redeploy -Dmaven.test.skip=true