加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

使用具有大(> 64k)模板的Groovy TemplateEngines

发布时间:2020-12-14 16:28:27 所属栏目:大数据 来源:网络整理
导读:如何使用SimpleTemplateEngine或GStringTemplateEngine处理大于65535个字符的模板? 我收到以下错误: groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not cur
如何使用SimpleTemplateEngine或GStringTemplateEngine处理大于65535个字符的模板?

我收到以下错误:

groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript1.groovy: 5614: String too long. The given string is 198495 Unicode code units long,but only a maximum of 65535 is allowed.

我正在使用以下代码构建模板:

def templateEngine = new SimpleTemplateEngine()
def binding = [:]
templateEngine
    .createTemplate(new FileReader("input.txt))
    .make(binding)
    .writeTo(new FileWriter(new File("output.txt")))

我发现JIRA 3487与此问题有关:GStringTemplateEngine fails to work with >64K strings .

我已经考虑过对输入进行分块,但这会带来它自身的复杂性,例如确保不要在表达式中间打破.

我将不胜感激任何其他建议.

解决方法

找到GStringTemplateEngine的一些替代品这些可以处理大型字符串.

https://github.com/mbjarland/groovy-streaming-template-engine

https://github.com/mbknor/gt-engine

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读