尝试在grails console
中运行以下命令:
Family.where() {password =~ "%qw%"}
对存储对象的非常简单的查询。我回来了:
ERROR groovy.lang.MissingMethodException:
No signature of method: com.babyboom.Family.where() is applicable for argument types: (groovysh_evaluate$_run_closure1) values: [groovysh_evaluate$_run_closure1@34356294]
Possible solutions: where(groovy.lang.Closure), merge(), every(), grep(), merge(com.babyboom.Family), merge(java.util.Map)
我知道我创建的关闭与预期的不同。
几个问题:
最佳答案
这可能是带有grails shell 的classloader错误。要重现,请向BuildConfig.gradle添加依赖项:
runtime "org.grails:grails-datastore-simple:3.1.2.RELEASE"
然后跑
import org.grails.datastore.mapping.simple.SimpleMapDatastore
import org.grails.datastore.gorm.GormStaticApi
class Bar {}
class Foo extends GormStaticApi<Bar> {
Foo() {
super(Bar, new SimpleMapDatastore(), [], null)
}
}
def f = new Foo()
在grails控制台中,产量:
Result: Foo@699c0395
在grails壳产量:
groovy:000> def f = new Foo()
ERROR java.lang.LinkageError:
loader constraint violation: when resolving overridden method "Foo.$getStaticMetaClass()Lgroovy/lang/MetaClass;" the class loader (instance of groovy/lang/GroovyClassLoader$InnerLoader) of the current class, Foo, and its superclass loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader), have different Class objects for the type ()Lgroovy/lang/MetaClass; used in the signature
关于grails - 贝壳和瓶盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25943957/