如何使用 ant 在 war 文件中创建和复制模板
How to create and copy templates in the war file using ant
我正在使用 jersey 开发 apache freemarker,我们在模板文件夹中提供 .ftl 模板,当我尝试创建一个 war 文件时,它没有创建模板。
<target name="war" depends="clean,compile,copy-resources">
<war destfile="${dist}/sample.war" webxml="WEB-INF/web.xml">
<fileset dir="WebContent"/>
<webinf dir="WEB-INF" includes="**/log4j.properties"></webinf>
<lib dir="${lib}"/>
<classes dir="${build}"/>
<templates dir="${templates}"/>
</war>
</target>
构建此代码时显示
war doesn't support the nested "templates" element.
class 正在添加 lib 文件夹,但未在 war 文件中创建模板文件夹。
谢谢,
Praveen R.
查看 war Task,并查看该页面中的示例。
但是,您应该使用 zipfileset
将您的 .ftl 文件包含在 war 中,它应该如下所示:
<zipfileset dir="${home.dir}/PATH_TO_FTL" includes="**/*.ftl" />
要创建和复制模板文件夹,请使用以下代码
<copy todir="${templates}">
要将此文件夹添加到 war 文件,请使用此代码
<webinf dir="WEB-INF" includes="**/log4j.properties,templates/"></webinf>
这解决了我的问题。
我正在使用 jersey 开发 apache freemarker,我们在模板文件夹中提供 .ftl 模板,当我尝试创建一个 war 文件时,它没有创建模板。
<target name="war" depends="clean,compile,copy-resources">
<war destfile="${dist}/sample.war" webxml="WEB-INF/web.xml">
<fileset dir="WebContent"/>
<webinf dir="WEB-INF" includes="**/log4j.properties"></webinf>
<lib dir="${lib}"/>
<classes dir="${build}"/>
<templates dir="${templates}"/>
</war>
</target>
构建此代码时显示
war doesn't support the nested "templates" element.
class 正在添加 lib 文件夹,但未在 war 文件中创建模板文件夹。
谢谢, Praveen R.
查看 war Task,并查看该页面中的示例。
但是,您应该使用 zipfileset
将您的 .ftl 文件包含在 war 中,它应该如下所示:
<zipfileset dir="${home.dir}/PATH_TO_FTL" includes="**/*.ftl" />
要创建和复制模板文件夹,请使用以下代码
<copy todir="${templates}">
要将此文件夹添加到 war 文件,请使用此代码
<webinf dir="WEB-INF" includes="**/log4j.properties,templates/"></webinf>
这解决了我的问题。