一,tomcat配置
在conf/tomcat-users.xml增加
<user username="admin" password="admin" roles="manager-gui, manager-script, manager-jmx, manager-status, admin-gui, admin-script"/>
二,maven setting.xml配置
<server>
<id>tomcat8</id>
<username>admin</username>
<password>admin</password>
</server>
三,项目pom.xml配置
<!-- tomcat插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://${tomcat.ip}/manager/text</url>
<server>${tomcat.name}</server>
<path>${tomcat.path}</path>
</configuration>
</plugin>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<tomcat.ip>127.0.0.1:8080</tomcat.ip>
<tomcat.path>/test-web</tomcat.path>
<tomcat.name>tomcat8</tomcat.name>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<tomcat.ip>10.1.255.100:8082</tomcat.ip>
<tomcat.path>/test-web</tomcat.path>
<tomcat.name>tomcat8</tomcat.name>
</properties>
</profile>
</profiles>
四,命令
mvn install tomcat7:redeploy -Pdev
五,验证方法
访问:
http://localhost:8080/manager/html
如出现输入用户名和密码弹框,则ok了。
六,补充
如果不行则需在conf/Catalina/localhost/
新建manager.xml
添加以下内容
<Context privileged="true" antiResourceLocking="false"
docBase="${catalina.home}/webapps/manager">
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
</Context>