ant釋出web專案,tomcat管理介面釋出war專案
阿新 • • 發佈:2019-02-05
今天用apache-ant-1.9.4 版本對 java web專案-adjustSolr 打包為war,併發布到tomcat中(一定要注意開發用的jdk版本和tomcat中的jdk版本一致,否則unsupport version51 錯誤)
貼build.xml檔案的程式碼
將build檔案下的war包放在tomcat6.5-jdk1.7或者其他tomcat下 部署即可:<?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 >
本地訪問連線:http://localhost:8082/adjustSolr/solrSearch.jsp
通過伺服器tomcat管理介面釋出: