1. 修改 tomat/conf/tomcat-users.xml
<role rolename="manager-gui"/> <role rolename="manager-script"/> <user username="tomcat" password="tomcat" roles="manager-gui,manager-script"/>
2. 在 maven 项目的 pom.xml 中 tomcat 插件的<configuration>里配置
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <port>80</port> <!-- 控制 tomcat 端口号 --> <path>/</path><!-- 项目发布到 tomcat 后的名称 --> <!-- / 相当于把项目发布名称为 ROOT --> <!-- /abc --> <username>tomcat</username> <password>tomcat</password> <url>http://192.168.139.128:8080/manager/text</url> </configuration> </plugin>
3. 右键项目--> run as --> maven build(选择第二个) -->输入
tomcat7:deploy 第一次发布
tomcat7:redeploy 不是第一次发布