国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

利用ant進行遠程tomcat部署

2019-11-14 22:29:46
字體:
來源:轉載
供稿:網友
利用ant進行遠程tomcat部署

javaEE項目中,需要將工程部署到遠程服務器上,如果部署的頻率比較高,手動部署的方式就比較麻煩,可以利用Ant工具實現快捷的部署。這篇博文詳細介紹了ant配置的步驟(http://m.survivalescaperooms.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中進行配置。加入以下代碼:

<role rolename="manager-script" />

<user username="用戶名"passWord="密碼" roles="manager-script">

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文件

<project name="工程名"default="redeploy" basedir=".">

<!-- Configure the directory into which the web application is built-->

<property name="build"value="${basedir}/build"/>

<!-- Configure the context path for this application -->

<property name="path" value="/應用的名稱"/>

<!-- Configure properties to access the Manager application -->

<property name="url"value="http://你的域名/manager/text"/>

<property name="username" value="步驟1中配置的用戶名"/>

<property name="password" value="步驟1中配置的密碼"/>

<!-- Configure the custom Ant tasks for the Manager application-->

<taskdef name="deploy"classname="org.apache.catalina.ant.DeployTask"/>

<taskdef name="list"classname="org.apache.catalina.ant.ListTask"/>

<taskdef name="reload"classname="org.apache.catalina.ant.ReloadTask"/>

<taskdef name="findleaks"classname="org.apache.catalina.ant.FindLeaksTask"/>

<taskdef name="resources"classname="org.apache.catalina.ant.ResourcesTask"/>

<taskdef name="start"classname="org.apache.catalina.ant.StartTask"/>

<taskdef name="stop"classname="org.apache.catalina.ant.StopTask"/>

<taskdef name="undeploy"classname="org.apache.catalina.ant.UndeployTask"/>

<!-- Executable Targets -->

<target name="compile" description="Compile webapplication">

<!-- ... construct web application in ${build} subdirectory, and

generated a ${path}.war ... -->

<deletedir="${build}"/>

<mkdir dir="${build}"/>

<wardestfile="${build}/school.war"webxml="WebRoot/WEB-INF/web.xml">

<classesdir="WebRoot/WEB-INF/classes">

<excludename="**/*.xml"/>

</classes>

<libdir="WebRoot/WEB-INF/lib" />

<fileset dir="WebRoot">

<includename="**/**.*" />

<excludename="**/*.jar"/>

<excludename="**/*.class"/>

</fileset>

</war>

</target>

<target name="deploy" description="Install webapplication" depends="compile">

<deploy url="${url}" username="${username}"password="${password}" path="${path}"war="${build}/school.war"/>

</target>

<target name="reload" description="Reload webapplication" depends="compile">

<reload url="${url}"username="${username}" password="${password}"path="${path}"/>

</target>

<target name="undeploy" description="Remove webapplication">

<undeploy url="${url}" username="${username}"password="${password}" path="${path}"/>

</target>

<targetname="redeploy" description="Remove and Install webapplication">

<antcalltarget="undeploy"/>

<antcalltarget="deploy"/>

</target>

</project>

最后運行該文件,你的工程就可以部署到遠程tomcat上了。

具體的說明可參考官方的文檔:

http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Executing_Manager_Commands_With_Ant


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 团风县| 涪陵区| 仙游县| 平和县| 盖州市| 淮阳县| 北安市| 通海县| 曲阳县| 宁德市| 建湖县| 汕头市| 潢川县| 新余市| 庐江县| 磐安县| 兴山县| 南宁市| 蒙阴县| 台北市| 嘉荫县| 新平| 申扎县| 柳江县| 新和县| 宁国市| 潮州市| 靖边县| 新竹市| 额敏县| 隆化县| 苍梧县| 太和县| 塔城市| 许昌县| SHOW| 永新县| 河津市| 陆川县| 金乡县| 尖扎县|