[英]Ant is not compiling *.properties files
I'm new to Ant and am having some issues compiling my project. 我是Ant的新手,在编译项目时遇到一些问题。 I have several
.properties
files in my project src/
. 我的项目
src/
有几个.properties
文件。 I'm compiling my project to a .WAR
via my build.xml
(posted below). 我正在通过
build.xml
将我的项目编译为.WAR
(在下面发布)。 When deploying, I see several FileNotFound
exceptions and even after unpacking the .WAR
file, I see that the *.properties
files are not present in my final distribution. 部署时,我看到了几个
FileNotFound
异常,甚至在解.WAR
文件后,我也发现*.properties
文件不存在于我的最终发行版中。 What am I doing wrong? 我究竟做错了什么? Thanks in advance.
提前致谢。
build.xml 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>
You simply did not include those properties files when calling the war
task. 调用
war
任务时,您只是不包括那些属性文件。 You should explicitly include them (I used a zipfileset
to add a prefix so that they are placed in the right path): 您应该明确包含它们(我使用
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>
Or as proposed by srkavin in the comments (but with some modification to include files in subdirectories): 或如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.