gpt4 book ai didi

grails - GRAILS:groovy.lang.MissingPropertyException:没有此类属性。

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

我正在尝试调试Grails应用程序。不幸的是,我没有上述语言的经验。

当我执行 grails generate-all org.example.Book 时,我得到了一个模糊的错误:

Generating controller for domain class org.example.Book ...
groovy.lang.MissingPropertyException: No such property: Event for class: SimpleTemplateScript6
at SimpleTemplateScript6.run(SimpleTemplateScript6.groovy:22)
at _GrailsGenerate_groovy.generateForDomainClass(_GrailsGenerate_groovy:88)
at _GrailsGenerate_groovy$_run_closure1.doCall(_GrailsGenerate_groovy:48)
at GenerateAll$_run_closure1.doCall(GenerateAll.groovy:42)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
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)
Error running generate-all: No such property: Event for class: SimpleTemplateScript6

查看生成的org.example.BookController.groovy源之后,我注意到它没有完全生成(在List字段= []处停止):
package org.example

// import needed for export plugin
import org.codehaus.groovy.grails.commons.ConfigurationHolder

class BookController {

...
def exportService

def export = {attrs ->
def response = attrs.response
List fields = []

此错误似乎是由template / scaffolding / Controller.groovy中的以下代码引起的:
<%=packageName ? "package ${packageName}\n\n" : ''%>

// import needed for export plugin
import org.codehaus.groovy.grails.commons.ConfigurationHolder

class ${className}Controller {

static allowedMethods = [save: "POST", update: "POST", delete: "POST"]^M

def exportService

...

def export = {attrs ->
def response = attrs.response
List fields = []
<% excludedProps = Event.allEvents.toList() << 'version'
allowedNames = domainClass.persistentProperties*.name << 'id' << 'dateCreated' << 'lastUpdated'
props = domainClass.properties.findAll { allowedNames.contains(it.name) && !excludedProps.contains(it.name) && !Collection.isAssignableFrom(it.type) }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
props.eachWithIndex {p, i -> %>fields.push("${p.name}"<%="\n"%><% } %>
Map labels = [:]
<% props.eachWithIndex { p, i -> %>labels.putAt("\${p.name}", "\${p.naturalName}")<%="\n "%><% } %>

Map formatters = [:]
Map parameters = [:]
response.setHeader("Content-disposition", "attachment; filename=${domainClass.propertyName}s.\${attrs.extension}")
if("\${attrs.extension}" == "xml") {
exportService.export(attrs.format, response.outputStream, attrs.exportList, fields, [:], formatters, parameters)
} else {
exportService.export(attrs.format, response.outputStream, attrs.exportList, fields, labels, formatters, parameters)
}
}
...
}

似乎def export {}块似乎引起了问题。上面的代码有什么问题吗?

最佳答案

什么是Event类?有进口吗?

关于grails - GRAILS:groovy.lang.MissingPropertyException:没有此类属性。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7589386/

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