我有一個Java Web應用程序。我將這個作爲一個使用Ant文件的戰爭部署到Tomcat服務器上。我可以成功地做到這一點。請在下面找到build.xml 現在的挑戰是我有我的應用程序下的web文件夾中的100000圖像複製到戰爭根文件夾。如何在tomcat上部署戰爭時跳過圖像
如果我在war文件的根文件夾中創建了100000個圖像的戰爭,那將是很頭疼的事情。
每當我改變JSP或Java代碼中的任何東西,新的戰爭再次將這些100000圖像複製到戰爭文件夾,這需要超過1小時建立戰爭文件。
如何確保我的圖像文件夾在戰爭中不會一次又一次地被複制到每次部署?
<!-- setting classpath -->
<path id="base.class.path">
<pathelement location="lib/joda-time-1.6.1.jar" />
<pathelement location="lib/fedExTrackingWebService.jar" />
....
.....
</path>
<property file="build.properties"/>
<path id="classpath">
<fileset dir="${lib.dir}"/>
</path>
<target name="clean">
<echo>Cleaning the ${build.dir}</echo>
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="init" depends="clean">
<echo>Creating the build directory</echo>
<mkdir dir="${build.dir}/WEB-INF/classes"/>
<mkdir dir="${build.dir}/WEB-INF/lib"/>
<mkdir dir="${dist.dir}"/>
</target>
<target name="compile" depends="init">
<echo>Compile the source files</echo>
<javac srcdir="${src.dir}" destdir="${build.dir}/WEB-INF/classes">
<classpath refid="base.class.path"/>
</javac>
</target>
<target name="copy" depends="compile">
<copy todir="${build.dir}/WEB-INF">
<fileset dir="${web.dir.webinf}/WEB-INF"/>
</copy>
<copy todir="${build.dir}">
<fileset dir="${web.dir}"/>
</copy>
<copy todir="${build.dir}/WEB-INF/lib">
<fileset dir="${lib.dir}">
</fileset>
</copy>
</target>
<target name="war">
<echo>Building the war file</echo>
<war destfile="${dist.dir}/${ant.project.name}.war" webxml="${build.dir}/WEB-INF/web.xml">
<fileset dir="${build.dir}"/>
</war>
</target>
<target name="deploy_local" depends="war">
<echo>Deploying .war to local Tomcat</echo>
<copy todir="${tomcat.dir}/webapps">
<fileset dir="${dist.dir}">
<include name="${ant.project.name}.war"/>
</fileset>
</copy>
</target>
請問您能更具體嗎?你如何創建戰爭文件? maven戰爭插件,螞蟻戰爭任務,jar -cf等? – lifus
它的螞蟻戰爭任務 - 請在構建文件上方找到。我正在部署使用螞蟻的戰爭。 – Gaurav
您可以嘗試在'war'任務中添加'update =「true」'。 – lifus