我在互联网上对此进行了广泛的研究,但找不到与我的情况相关的任何内容。
我目前有一个带有 grails 2.5 的项目,我正在使用 Intellij 14.1.3。
从 14.1 开始,Intellij 允许使用 groovy eclipse 编译器。我下载了编译器的适当版本(2.4.3)以在我的项目中使用。
每当我尝试编译时,我都会在类中遇到这些错误(它只发生在 spock 规范中)
2015-07-06 13:35:18,677 [13475148] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: General error during canonicalization: java.lang.NoClassDefFoundError: junit/framework/TestCase
2015-07-06 13:35:18,677 [13475148] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: java.lang.RuntimeException: java.lang.NoClassDefFoundError: junit/framework/TestCase
2015-07-06 13:35:18,677 [13475148] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: at org.codehaus.groovy.control.CompilationUnit.convertUncaughtExceptionToCompilationError(CompilationUnit.java:1257)
随后在堆栈跟踪中进一步向下:
2015-07-06 13:35:18,678 [13475149] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.grails.compiler.injection.test.MockTransformation
2015-07-06 13:35:18,678 [13475149] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
2015-07-06 13:35:18,678 [13475149] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
2015-07-06 13:35:18,678 [13475149] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
2015-07-06 13:35:18,678 [13475149] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
2015-07-06 13:35:18,678 [13475149] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: at java.lang.Class.newInstance(Class.java:383)
2015-07-06 13:35:18,678 [13475149] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:99)
2015-07-06 13:35:18,678 [13475149] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:227)
2015-07-06 13:35:18,678 [13475149] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1221)
2015-07-06 13:35:18,678 [13475149] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: ... 32 more
这些错误看起来很简单:一个缺失的类。但是,如果我切换回普通编译器,一切正常。