gpt4 book ai didi

grails - 贝壳和瓶盖

转载 作者:行者123 更新时间:2023-12-02 14:51:36 26 4
gpt4 key购买 nike

尝试在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)

我知道我创建的关闭与预期的不同。
几个问题:
  • 为什么有两种类型的闭包?
  • 找到Why am I getting a "No signature of method"" error when running the closure recursion example in the Groovy shell?尝试了一下,但没有帮助,仍然出现相同的错误
  • 使用grails控制台时效果很好
  • 最佳答案

    这可能是带有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/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com