如何進行WEB應用打包

來源:互聯網
上載者:User

一個Web 應用程式發布到Jboss 伺服器時需要打成war包。
下面介紹jar命令列及Ant任務兩種war檔案的打包方式。

1.命令列下進行war 檔案打包。
在Dos 視窗中進入到WEB 應用根目錄下(WebRoot下),執行如下命令,如:
jar cvf EJBClient.war *,再把打包的EJBClient.war拷貝到C:\jboss-5.0.0.GA\server\default\deploy發布。

2.在Ant 任務中進行war檔案打包。
build.xml檔案如下:
 <?xml version="1.0" encoding="UTF-8"?>
<project name="EJBClient" default="war" basedir=".">
 <property environment="env" />
 <property name="jboss.home" value="${env.JBOSS_HOME}" />
 <property name="jboss.server.config" value="default" />
 <target name="war" description="建立WEB 發布包">
  <war warfile="${basedir}/${ant.project.name}.war" webxml="${basedir}/WebRoot/WEB-INF/web.xml">
   <classes dir="${basedir}/WebRoot/WEB-INF/classes">
    <include name="**/*.class" />
   </classes>
   
   <lib dir="${basedir}/WebRoot/WEB-INF/lib">
    <include name="*.jar" />
   </lib>
   
   <webinf dir="${basedir}/WebRoot">
    <include name="*.*" />
   </webinf>
  </war>
 </target>
 
 <target name="deploy" depends="war" description="發布WAR">
  <copy file="${basedir}\${ant.project.name}.war" todir="${jboss.home}\server\${jboss.server.config}\deploy"/>
 </target>
 
 <target name="undeploy"  description="卸載WAR">
  <delete file="${jboss.home}\server\${jboss.server.config}\deploy\${ant.project.name}.war"/>
 </target>
</project>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.