如何使用SimpleTemplateEngine或GStringTemplateEngine处理大于65535个字符的模板?
我收到以下错误:
groovy.lang.GroovyRuntimeException:无法解析模板脚本(您的模板可能包含错误或尝试使用当前不支持的表达式):startup failed:SimpleTemplateScript1.groovy:5614:String太长.给定的字符串长度为198495 Unicode代码单元,但最多只允许65535.
我正在使用以下代码构建模板:
def templateEngine = new SimpleTemplateEngine()
def binding = [:]
templateEngine
.createTemplate(new FileReader("input.txt))
.make(binding)
.writeTo(new FileWriter(new File("output.txt")))
Run Code Online (Sandbox Code Playgroud)
我发现JIRA 3487与此问题有关:GStringTemplateEngine无法使用> 64K字符串.
我已经考虑过对输入进行分块,但这会带来它自身的复杂性,例如确保不要在表达式中间打破.
我将不胜感激任何其他建议.
GStringTemplateEngine找到了These can can handle large Strings的一些替代品。
https://github.com/mbjarland/groovy-streaming-template-engine
https://github.com/mbknor/gt-engine