您的位置:首页 > 运维架构 > Tomcat

远程部署Tomcat

2010-01-17 19:58 190 查看
Step1) 配置客户端
将服务端的${CATALINA_HOME}/lib/catalina-ant.jar拷贝到客户端的${ANT_HOME}/lib
客户端的${ANT_HOME}在本文中指的是D:/dev/eclipse/plugins/org.apache.ant_1.6.5/lib
即eclipse自带的ant目录,为了让eclipse自带的ant能正常运行任务,你还得将这个jar添加到eclipse的ant的classpath中(windows-->preferences-->Ant-->runtime-->classpath)

你完全可以不使用eclipse自带的ant,上面的步骤显得很麻烦,你完全可以开启dos窗口运行ant,但这样的话你就的两边切换窗口,一边在eclipse下写代码,一边在dos下运行ant,根据的自己的实际情况取舍吧

Step2) 配置服务器
我们主要通过tomcat manager api来完成部署工作,这个需要权限,所以你的修改
$CATALINA_HOME/conf/tomcat-users.xml加入

<user name="craigmcc" password="secret" roles="manager" />

<project name="My Application" default="war" basedir=".">

<!-- Configure the directory into which the web application is built -->
<property name="build" value="${basedir}/WebRoot/WEB-INF/classes" />
<property name="dist.dir" value="${basedir}/dist" />

<!-- Configure the context path for this application -->
<property name="path" value="/MFMS" />

<!-- Configure properties to access the Manager application -->
<property name="url" value="http://192.168.23.165:8085/manager" />
<property name="username" value="admin" />
<property name="password" value="admin" />

<!-- Configure the custom Ant tasks for the Manager application -->
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask" />
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask" />

<!-- Executable Targets -->

<target name="war" description="package web application">
<war destfile="${dist.dir}/MFMS.war" webxml="WebRoot/WEB-INF/web.xml">
<classes dir="WebRoot/WEB-INF/classes" />
<fileset dir="WebRoot" excludes="WEB-INF/**" />
<lib dir="WebRoot/WEB-INF/lib" />
</war>
</target>

<target name="deploy" description="Install web application" depends="war">
<deploy url="${url}" username="${username}" password="${password}" path="${path}" war="${dist.dir}/MFMS.war" />
</target>

<target name="undeploy" description="Remove web application">
<undeploy url="${url}" username="${username}" password="${password}" path="${path}" />
</target>

</project>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: