1. 开启远程访问

a.打开若没有则新建/conf/Catalina/localhost/manager.xml

内容为:

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

b.修改/webapps/manager/META-INF/context.xml,注释掉value里内容

<Context antiResourceLocking="false" privileged="true" >
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
</Context>
改为
<Context antiResourceLocking="false" privileged="true" >
    <!--
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
    -->
</Context>
或
<Context antiResourceLocking="false" privileged="true" >
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="d+\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
</Context>

2.修改tomcat-users.xml,添加角色和用户,加script是因为远程maven部署用

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

注意对于tomcat9来说,不能同时赋予用户manager-script和manager-gui角色。