maven tomcat7 自动部署

来源:互联网 发布:蝙蝠侠 知乎 编辑:程序博客网 时间:2024/05/17 00:14


假设项目名字为myApp

step1:

pom.xml 中在build里面加入

<plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><version>2.2</version><configuration><url>http://localhost:8080/manager/text</url><server>TomcatServer</server><path>/myApp</path></configuration></plugin>



step2:

进入tomcat安装目录下

找到 webapps\manager\WEB-INF 的web.xml 将下列东西注释掉,(取消访问需要的权限)

<!-- NOTE:  None of these roles are present in the default users file   <security-constraint>    <web-resource-collection>      <web-resource-name>HTML Manager interface (for humans)</web-resource-name>      <url-pattern>/html/*</url-pattern>    </web-resource-collection>    <auth-constraint>       <role-name>manager-gui</role-name>    </auth-constraint>  </security-constraint>  <security-constraint>    <web-resource-collection>      <web-resource-name>Text Manager interface (for scripts)</web-resource-name>      <url-pattern>/text/*</url-pattern>    </web-resource-collection>    <auth-constraint>       <role-name>manager-script</role-name>    </auth-constraint>  </security-constraint>  <security-constraint>    <web-resource-collection>      <web-resource-name>JMX Proxy interface</web-resource-name>      <url-pattern>/jmxproxy/*</url-pattern>    </web-resource-collection>    <auth-constraint>       <role-name>manager-jmx</role-name>    </auth-constraint>  </security-constraint>  <security-constraint>    <web-resource-collection>      <web-resource-name>Status interface</web-resource-name>      <url-pattern>/status/*</url-pattern>    </web-resource-collection>    <auth-constraint>       <role-name>manager-gui</role-name>       <role-name>manager-script</role-name>       <role-name>manager-jmx</role-name>       <role-name>manager-status</role-name>    </auth-constraint>  </security-constraint>-->  <!-- Define the Login Configuration for this Application   <login-config>    <auth-method>BASIC</auth-method>    <realm-name>Tomcat Manager Application</realm-name>  </login-config>-->  <!-- Security roles referenced by this web application   <security-role>    <description>      The role that is required to access the HTML Manager pages    </description>    <role-name>manager-gui</role-name>  </security-role>  <security-role>    <description>      The role that is required to access the text Manager pages    </description>    <role-name>manager-script</role-name>  </security-role>  <security-role>    <description>      The role that is required to access the HTML JMX Proxy    </description>    <role-name>manager-jmx</role-name>  </security-role>  <security-role>    <description>      The role that is required to access to the Manager Status pages    </description>    <role-name>manager-status</role-name>  </security-role>-->

step3: 写一个批处理 autoDeploy.bat


set myProject=.......\workspace\myAppset myTomcat=.....\apache-tomcat-7.0.70set myAppName=myAppcd %myProject%call mvn cleancall mvn installif not exist %myTomcat%\webapps\%myAppName% (call mvn tomcat7:deploy) else (call mvn tomcat7:redeploy)pause

再将autoDeploy.bat 所在的目录设置到 PATH 里面,这样就可以打开cmd,直接输入autoDeploy,完成tomcat的自动部署了

可以在 localhost:8080/manager   里面看到增加了一个项目,直接点击就可以打开网页啦

0 0
原创粉丝点击