finatra使用mustache模板,本地文件配置

了便于调试方便,本地的*.mustache模板,需要从硬盘读取,不需要做cache缓存.类似nginx的lua也有cache开关

1) 设置ide的运行参数

-http.port=:5000 -local.doc.root=F:\template

调试模式使用 local.doc.root标志将会触发本地文件模式.(Finatra版本> v1.x) 

不能同时使用 local.doc.root + doc.root 

官方文档的描述如下:

To serve files from the local filesystem, set the flag -local.doc.root to the location of the file serving directory. Note that setting Java System Property -Denv=env is no longer required nor supported. Setting the -local.doc.root flag will trigger the same localFileMode behavior from Finatra v1.x.

Also note that it is an error to attempt to set both the -doc.root and the -local.doc.root flags. Either

  • do nothing to load resources from the classpath root or

  • configure a classpath “namespace” by setting the -doc.root or

  • load files from a local filesystem directory location specified by the -local.doc.root flag.

Additionally, it is recommend to use local filesystem serving only during testing and not in production. It is recommended that you include files to be served as classpath resources in production.

如果是生产环境,则需要使用-doc.root来配置classpath

关于template模板文件,具体在哪个目录下面,可以通过变量设置

默认是在resources目录下面,当然也可以修改

-mustache.templates.dir=newtemplate

-mustache.templates.dir=com\web_test\templatesxxabc

这样可以将模板文件通过cache缓存起来.

resources\newtemplate\abc.mustache

注意:

同时设置2个参数,会冲突,将会提示:

4) Error injecting constructor, java.lang.AssertionError: assertion failed: Cannot set both -local.doc.root and -doc.root flags.

  at com.twitter.finatra.http.routing.FileResolver.<init>(FileResolver.scala:28)

  at com.twitter.finatra.http.routing.FileResolver.class(FileResolver.scala:27)


转载于:https://my.oschina.net/u/1538135/blog/657252

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值