[英]Ant is not compiling *.properties files
我是Ant的新手,在編譯項目時遇到一些問題。 我的項目src/
有幾個.properties
文件。 我正在通過build.xml
將我的項目編譯為.WAR
(在下面發布)。 部署時,我看到了幾個FileNotFound
異常,甚至在解.WAR
文件后,我也發現*.properties
文件不存在於我的最終發行版中。 我究竟做錯了什么? 提前致謝。
build.xml文件
<?xml version="1.0" ?>
<project name="APP" default="war">
<path id="compile.classpath">
<fileset dir="WebContent/WEB-INF/lib">
<include name="*.jar" />
</fileset>
</path>
<target name="init">
<mkdir dir="build/classes" />
<mkdir dir="dist" />
</target>
<target name="compile" depends="init">
<javac destdir="build/classes" includeantruntime="false" debug="true" srcdir="src">
<classpath refid="compile.classpath" />
</javac>
</target>
<target name="war" depends="compile">
<war destfile="dist/APP.war" webxml="WebContent/WEB-INF/web.xml" duplicate="preserve">
<fileset dir="WebContent" />
<lib dir="WebContent/WEB-INF/lib" />
<classes dir="build/classes" />
</war>
</target>
調用war
任務時,您只是不包括那些屬性文件。 您應該明確包含它們(我使用zipfileset
添加前綴,以便將它們放置在正確的路徑中):
<war destfile="dist/APP.war" webxml="WebContent/WEB-INF/web.xml" duplicate="preserve">
<fileset dir="WebContent" />
<zipfileset dir="src"
prefix="WEB-INF/classes">
<include name="**/*.properties"/>
</zipfileset>
<lib dir="WebContent/WEB-INF/lib" />
<classes dir="build/classes" />
</war>
或如srkavin在評論中所建議的(但進行了一些修改以在子目錄中包含文件):
<war destfile="dist/APP.war" webxml="WebContent/WEB-INF/web.xml" duplicate="preserve">
<fileset dir="WebContent" />
<lib dir="WebContent/WEB-INF/lib" />
<classes dir="build/classes" />
<classes dir="src" includes="**/*.properties"/>
</war>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.