如何在不重新启动速度的情况下编辑 velocmacro?
我的速度宏正在被缓存,我不希望它们......至少在开发过程中。
我已经在属性文件中设置了以下属性...
velocimacro.library.autoreload=true
file.resource.loader.cache=false
velocity.engine.resource.manager.cache.enabled=false
...但这似乎并没有达到目的
使用速度属性,如何配置速度以不缓存宏?
(我正在使用速度 1.6.4)
编辑:
我不认为该行...
velocity.engine.resource.manager.cache.enabled=false
...与速度相关
My velocity macros are being cached and I don't want them to be... not during development at least.
I've set the following properties in my properties file...
velocimacro.library.autoreload=true
file.resource.loader.cache=false
velocity.engine.resource.manager.cache.enabled=false
... but this doesn't seem to have done the trick
Using velocity properties, how can I configure velocity to not cache macros?
(I'm using velocity 1.6.4)
EDIT:
I don't think the line...
velocity.engine.resource.manager.cache.enabled=false
...is relevant to velocity
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我在 NVelocity(C# 速度端口)方面也遇到了同样的问题。深入研究他们的来源,我发现全局名称空间中宏的重新加载是由以下属性控制的。
我还没有用速度对此进行测试,但查看了他们的 文档该属性存在并且似乎完全符合您的需要。
I have been having the same issue with NVelocity (C# port of velocity). Digging through their souce I found that the re-loading of the macros in the global name space are controlled by the following property.
I havn't tested this with velocity but looking at their documentation the property exists and seem to do exactly what you need.
看来你不能做你想做的事。我可以重新加载宏定义的唯一方法是将它们放入自己的库文件中并设置 velocimacro.library.autoreload = true。
来自 http://velocity.apache.org/engine/devel/developer-guide .html
Looks like you cant do what you want. The only way I could get macro definitions to reload is to put them in their own library file and set the velocimacro.library.autoreload = true.
From http://velocity.apache.org/engine/devel/developer-guide.html
如果宏不在速度库中而仅在某个模板文件中,我不确定这是否可行。
但是,在这种情况下,如果您只是想让开发更容易,您可以重命名宏(通过执行查找/替换全部,然后在末尾添加一个数字或其他内容)。然后您应该能够立即看到变化。您只需要记住完成后将其重命名回原来的名称即可!
I'm not sure this is possible if the macros are not in a velocity library and just in some template file.
However, in this case, if you just want to make development easier, you can just rename the macro (by doing a find/replace all and just adding a number to the end or something). Then you should be able to see the change straight away. You just have to remember to rename it back to what it's supposed to be when your finished!
您可能需要设置
这告诉速度检查文件是否已更改的频率。我无法从文档中得知默认值是什么,但我们在开发环境中将默认值设置为 2。可能只是这个属性的默认值是一个很大的数字或小于 0,这本质上是关闭的,这意味着它永远不会检查宏文件中的更改。
You might need to set
This tells velocity how often to check if the file has changed. I can't tell from the docs what the default is, but we have ours set to 2 in our dev env. It might just be that the default value for this prop is a high number or less than 0 which is essentially off, meaning it will never check for changes in your macro file.
您可能想使用#define 指令而不是#macro。这些参考文献可能会发生变化。
使用它,您还可以命名 VTL 代码块并根据需要调用它多次。
将宏参数定义为同一上下文中的变量,并在命名块中使用它们,就像它是宏一样。
两者都可以解决常见情况;但它们并不等同。
https://velocity.apache.org/engine/1.7/user- Guide.html#define
You may want to use the #define directive instead of #macro. Theses references can change.
With it you can also name a block of VTL code and call it how many times you need it.
Define the macro arguments as variables in the same context and use them within the named block as if it were a macro.
Both can solve common situations; but they are not equivalent.
https://velocity.apache.org/engine/1.7/user-guide.html#define