Ant学习系列 -- Web项目发布到远程服务器上

在开发过程中,需要将本地项目发布到远程服务器上,以下是记录整个实现的过程。
环境:
1 Tomcat6、eclipse-jee-helios
步骤:
1  打开Eclipse的Window -> Preferences -> Ant -> Runtime -> Classpath
   在Global Entries下面添加catalina-ant.jar包
2  在工程目录下建立build.ant,下面表示将当前项目打包成IHBS.war,并发布到远程Tomcat的webapp目录下。Build.ant文件如下
<project name="My Application" default="deploy" basedir=".">
 
<!-- Configure the directory into which the web application is built -->
<property name="build" value="${basedir}/build/classes" />
<property name="dist.dir" value="${basedir}" />
 
<!-- Configure the context path for this application -->
<property name="path" value="/IHBS" />
 
<!-- Configure properties to access the Manager application -->
<property name="url" value="http://10.30.4.89:8999/manager" />
<property name="username" value="admin" />
<property name="password" value="admin" />
 <!--
	<user username="zwankeji_admin" password="!zwankeji!" roles="manager"/>
	-->
<!-- 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}/IHBS.war" webxml="WebContent/WEB-INF/web.xml">
     <classes dir="${build}" />
     <fileset dir="WebContent" />
 	<lib dir="WebContent/WEB-INF/lib" />
</war>
</target>
 
<target name="deploy" description="Install web application" depends="war,undeploy">
<deploy url="${url}" username="${username}" password="${password}" path="${path}" war="${dist.dir}/IHBS.war" />
</target>
 
 
<target name="undeploy" description="Remove web application">
<undeploy url="${url}" username="${username}" password="${password}" path="${path}" />
</target>
 
</project>

其中
<property name="url" value="http://10.36.24.37:8787/manager" />
<property name="username" value="zwankeji_admin" />
<property name="password" value="!zwankeji!" />
中:
url 表示要发布程序所在服务器
username:tomcat密码
password:tomcat密码

target功能说明:
war:表示将当前项目打包成IHBS.war
deploy:将本IHBS.war发布到远程服务器目录下
undeploy:从远程服务器上删除IHBS.war文件

3 通过执行build.ant文件即可将IHBS发布到远程服务器


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值