ant發布web項目,tomcat管理介面發布war項目

來源:互聯網
上載者:User

標籤:ant編譯 tomcat發布

今天用apache-ant-1.9.4 版本對 java web項目-adjustSolr 打包為war,並發布到tomcat中(一定要注意開發用的jdk版本和tomcat中的jdk版本一致,否則unsupport version51 錯誤)

貼build.xml檔案的代碼

<?xml version="1.0"  encoding="UTF-8"?>  <project  name ="adjustSolr"   default ="war" basedir ="."> <property name="catalina.home" value="D:/tomcat6.5-jdk1.7" />  <property  name ="build.dir" value ="build"/> <property  name ="lib.dir" value ="WebContent/WEB-INF/lib"/><property name="webRoot.dir" value="WebContent" />  <property name="classes.dir" value="build/classes" />  <path id="project.classpath">   <fileset dir="${lib.dir}" includes="***.jar" />   <!-- 添加tomcat類路徑 -->          <fileset dir="${catalina.home}/lib">              <include name="*.jar" />          </fileset>  </path><pathconvert pathsep="${line.separator}|   |-- "               property="echo.path.compile"               refid="project.classpath">  </pathconvert> <!-- 建立目錄結構 -->  <target name="init" depends="clear" description="建立初始化目錄結構">          <mkdir dir="${build.dir}" />  <mkdir dir="${classes.dir}" />  </target>  <!-- javac編譯任務  --><target  name="compile"  depends="init"  description="編譯java檔案為javac檔案" >    <javac  srcdir="src"  destdir="${classes.dir}" includeantruntime="false" nowarn="on"               source="1.7" target="1.7" deprecation="true" debug="true"               encoding="UTF-8" classpathref="project.classpath" >     <compilerarg line="-Xlint:unchecked" />   </javac>   </target><!-- war打包任務 --><target name="war"  depends="compile"    description="打包為adjustSolr.war檔案">    <echo message="begin war..." />  <war destfile="${build.dir}/${ant.project.name}.war"  webxml="WebContent/WEB-INF/web.xml"><fileset dir="${webRoot.dir}" /><lib dir="${lib.dir}"/><classes dir="${classes.dir}"/></war></target><!--clean任務   --><target  name ="clear"> <delete  dir ="build"/> </target > </project >
將build檔案下的war包放在tomcat6.5-jdk1.7或者其他tomcat下  部署即可:

本地訪問串連:http://localhost:8082/adjustSolr/solrSearch.jsp

通過伺服器tomcat管理介面發布:



ant發布web項目,tomcat管理介面發布war項目

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.