Grails 缺少属性异常

发布于 2024-11-19 19:32:00 字数 1326 浏览 4 评论 0原文

我遇到了一个奇怪的错误,导致我整个上午都挂断了电话。我有一个带有 Person 类的 Grails 应用程序,如下所示:

class Person {
        String id
    Date   lastUpdated
    String note
    String lastName
    String firstName
    String middleName
    String facility
    ...
}

在我的控制器中,我有一个闭包来获取模型:

def personDetail = {
    Person person = new Person()
    ...
    List<Person> personSearchList = session.getAttribute("searchResults")
    Person selectedSearchPerson = selectedSearchPersonList.find { it.id == selectedID }
    person.firstName = selectedSearchPerson.firstName
    person.lastName = selectedSearchPerson.lastName
    person.middleName = selectedSearchPerson.middleName
    person.facility = selectedSearchPerson.facility
    ...
    return [person:person]
}

现在,这段代码昨天工作正常。然而,今天早上,在没有进行任何修改的情况下(我什至尝试恢复到较旧的 svn 提交),当我单击 g:link 显示detailController gsp 时,我收到以下错误:

groovy.lang.MissingPropertyException: No such property: facility for class: org.icf.Person
at org.bjc.icf.DetailController$_closure3.doCall(DetailController.groovy:33)
at org.bjc.icf.DetailController$_closure3.doCall(DetailController.groovy)
at java.lang.Thread.run(Thread.java:619)

我尝试查找可能的解决方案在线导致此错误,但我似乎找不到任何内容。有谁知道为什么我可能会突然在以前工作的代码上遇到 MissingPropertyExceptions (是的,我已经检查以确保该属性仍在类中)。

I've been getting a strange error that has had me hung up all morning. I have a Grails application with a Person class that looks like this:

class Person {
        String id
    Date   lastUpdated
    String note
    String lastName
    String firstName
    String middleName
    String facility
    ...
}

In my controller, I have a closure to obtain the model:

def personDetail = {
    Person person = new Person()
    ...
    List<Person> personSearchList = session.getAttribute("searchResults")
    Person selectedSearchPerson = selectedSearchPersonList.find { it.id == selectedID }
    person.firstName = selectedSearchPerson.firstName
    person.lastName = selectedSearchPerson.lastName
    person.middleName = selectedSearchPerson.middleName
    person.facility = selectedSearchPerson.facility
    ...
    return [person:person]
}

Now, this code was working fine yesterday. This morning however, without making any modifications (I have even tried reverting to older svn submissions) I am getting the following error when I click the g:link to display the detailController gsp:

groovy.lang.MissingPropertyException: No such property: facility for class: org.icf.Person
at org.bjc.icf.DetailController$_closure3.doCall(DetailController.groovy:33)
at org.bjc.icf.DetailController$_closure3.doCall(DetailController.groovy)
at java.lang.Thread.run(Thread.java:619)

I've tried looking up a solution to what might be causing this error online but I can't seem to find anything. Does anyone have any idea why I might all of a sudden be getting MissingPropertyExceptions on previously working code (and yes, I have checked to make sure the property is still in the class).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无力看清 2024-11-26 19:32:00

尝试运行grails clean - 有时增量编译会失败,因此强制完整编译通常会消除此类奇怪的问题。

Try running grails clean - sometimes incremental compilation fails so forcing a full compile will often make weird issues like this go away.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文