1. 程式人生 > >maven tomcat8 遠端部署(支援tomcat7)

maven tomcat8 遠端部署(支援tomcat7)

①修改tomcat的conf資料夾下的tomcat_user.xml

<role rolename="manager"/> 
<role rolename="manager-gui"/> 
<role rolename="admin"/> 
<role rolename="admin-gui"/> 
<role rolename="manager-script"/>
<user username="tomcat" password="tomcat" roles="admin-gui,admin,manager-gui,manager,manager-script"/>

apache-tomcat-8.5.4/conf/Catalina/localhost下增加檔案

manager.xml

<Context privileged="true" antiResourceLocking="false"   
         docBase="${catalina.home}/webapps/manager">  
     <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />  
</Context>

②啟動tomcat

③修改pom.xml的<build>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8084/manager/text</url>
<username>tomcat</username>
<password>tomcat</password>
</configuration>
</plugin>
</plugins>
<build>

 修改maven的 settings.xml

<server>
<id>tomcat</id>
<username>tomcat</username>
<password>tomcat</password>
</server>


④命令

mvn tomcat7:deploy

或者mvn tomcat7:redeploy