Maven原型+速度:如何显示日期 [英] Maven archetype + Velocity: how to show the date
问题描述
我有一个Maven原型项目.当我使用此原型时,我希望某些文件报告实际日期.我用$ date尝试过,但是Velocity无法识别它.我找到了一个叫做DateTools的东西,但是我不知道如何使用它.这是我第一次使用Velocity.
I have a maven archetype project. When I use this archetype I want that some files report the actual date. I tried with $date but Velocity does not recognize it. I found something called DateTools but I don't know how can I use it. It's the first time I use Velocity.
推荐答案
不幸的是,Maven Archetype插件未与Velocity Tools捆绑在一起.我通过修改Maven原型插件添加了它.假设您正在使用Maven 2.2.1,请按照以下步骤操作:
Unfortunately, the Maven Archetype plugin doesn't come bundled with Velocity Tools. I've added it by modifying the Maven Archetypes Plugin. Follow these steps, presuming you're using Maven 2.2.1:
svn co -q http://svn.apache.org/repos/asf/maven/archetype/tags/maven-archetype-2.2
cd maven-archetype-2.2
curl -k -O https://raw.github.com/gist/3404715/59c7fa1c20c60e2a165de4109c2acffb8026febd/velocity-tools.patch
patch -p0 -i velocity-tools.patch
mvn install
修改后的Maven Archetype插件现在将在本地安装.
The modified Maven Archetype plugin will now be installed locally.
$date
用法现在应呈现,例如
$date
usage in your templates should now render, e.g.
The date is $date
...发送至:
The date is Aug 20, 2012 4:40:22 PM
这篇关于Maven原型+速度:如何显示日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!