利用ant进行远程tomcat部署
在javaEE项目中,需要将工程部署到远程服务器上,如果部署的频率比较高,手动部署的方式就比较麻烦,可以利用Ant工具实现快捷的部署。这篇博文详细介绍了ant配置的步骤(http://www.iyunv.com/GloriousOnion/archive/2012/12/18/2822817.html),但是在tomcat7以上不适用,需要修改配置,具体如下:1.配置tomcat的用户角色
tomcat7中的用户角色有:
manager-gui — Access to the HTML interface.
manager-status — Access to the "Server Status" page only.
manager-script — Access to the tools-friendly plain text interface that isdescribed in this document, and to the "Server Status" page.
manager-jmx — Access to JMX proxy interface and to the "ServerStatus" page.
我们要用到的是manager-script,在tomcat-users.xml 中进行配置。加入以下代码:
2.配置Ant环境
以前在 6.0 的时候, 我们会在 classpath中加入catalina-ant.jar 包,具体操作为 :window-->preferences,左边:ant-->runtime,在右边的 classpath标签中的global entries 下加入 external jars,路径指向 tomcat_home/lib/catalina-ant.jar, 只需这一个即可,但是现在 7.0得再加几个才行:
lib/catalina-ant.jar,lib/tomcat-coyote.jar,lib/tomcat-util.jar,bin/tomcat-juli.jar 3.编写build.xml文件
最后运行该文件,你的工程就可以部署到远程tomcat上了。
具体的说明可参考官方的文档:
http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Executing_Manager_Commands_With_Ant
页:
[1]