我正在尝试为我的grails项目创建一个UrlMappingsTest,并且我遇到以下异常:
java.lang.RuntimeException: Could not load class in test type 'integration'
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:391)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
我的课很简单,我试着按照这个例子。发生了什么事?
import grails.test.GrailsUrlMappingsTestCase
class UrlMappingTests extends GrailsUrlMappingsTestCase {
// static mappings = UrlMappings
void testForwardingUrls(){
assertForwardUrlMapping( "/rest/users/stefan/files", controller: "file", action: "allFiles" );
}
}
取消注释静态行,我得到了
[groovyc] You attempted to reference a variable in the binding or an instance variable from a static context.
[groovyc] You misspelled a classname or statically imported field. Please check the spelling.
[groovyc] You attempted to use a method 'UrlMappings' but left out brackets in a place not allowed by the grammar.
[groovyc] @ line 7, column 21.
[groovyc] static mappings = UrlMappings
[groovyc]
^
答案 0 :(得分:0)
如果您查看GrailsUrlMappingsTestCase
static mappings = UrlMappings
,您会看到(因为您可能怀疑)java.lang.RuntimeException: Could not load class in test type 'integration'
不需要,因为如果您不这样做,默认会这样做t指定静态映射变量。当您离开注释掉的行时,您是否在{{1}}下获得了嵌套异常?发布完整的堆栈跟踪,它应该工作。您使用的是什么版本的Grails?
答案 1 :(得分:0)
我已在grails bugtracker上为此记录了一张票。