使用Groovy模板引擎时的编译器异常

时间:2016-01-18 09:24:06

标签: groovy

当我尝试使用groovy模板引擎时,我收到以下错误。有趣的是从IntelliJ运行导致没有错误。是否存在一些我遗漏的依赖项?

我必须将以下注释添加到我的unitTest以使其通过,也许这会导致它

@RunWith(org.powermock.modules.junit4.PowerMockRunner.class)
@PowerMockIgnore({"org.xml.*", "javax.xml.*"})

的build.gradle

 compile 'org.codehaus.groovy:groovy-all:2.4.5'

代码

  Template template = engine.createTemplate(new InputStreamReader(ABC.class
                .getClassLoader()
                .getResourceAsStream("template/graph.template")));

模板

html{
   head {
      title("${projectName}-${configName}")
      script( '', type:'text/javascript', src:'../resources/js/d3.min.js' )
      script( '', type:'text/javascript', src:'../resources/js/dagre-d3.min.js' )
      link(href:'../resources/css/dep.css', rel:"stylesheet", type:"text/css")

title('Dependency Graph')
svg ('',width:960,height:600)
script('',"\n var nodes = " + nodeArray + ";\n" +  " var edges = " + edgesArray + ";\n")
   }
   script( '', type:'text/javascript', src:'../resources/js/dep.js' )
}

堆栈跟踪

java.lang.NoSuchMethodError: org.codehaus.groovy.classgen.ReturnAdder.<init>(Lorg/codehaus/groovy/classgen/ReturnAdder$ReturnStatementListener;)V
    at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.<init>(StaticTypeCheckingVisitor.java:186)
    at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.<init>(StaticCompilationVisitor.java:76)
    at org.codehaus.groovy.transform.sc.StaticCompileTransformation.newVisitor(StaticCompileTransformation.java:94)
    at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.java:189)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.call(ASTTransformationCustomizer.groovy:222)
    at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:967)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:546)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:524)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:501)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:267)
    at groovy.text.markup.MarkupTemplateEngine$TemplateGroovyClassLoader.parseClass(MarkupTemplateEngine.java:252)
    at groovy.text.markup.MarkupTemplateEngine$MarkupTemplateMaker.<init>(MarkupTemplateEngine.java:204)
    at groovy.text.markup.MarkupTemplateEngine.createTemplate(MarkupTemplateEngine.java:137)
    at com.xx.generateGraph(StpDepGraph.java:79)
    at com.xx.lambda$buildDependencySTP1X$1(StpDepGraph.java:134)
    at com.xx$$Lambda$8/172869285.accept(Unknown Source)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1612)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Collections$2.tryAdvance(Collections.java:4776)
    at java.util.Collections$2.forEachRemaining(Collections.java:4784)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)

0 个答案:

没有答案