我有一个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