Grails MissingPropertyException

Mik*_*uto 1 grails groovy runtime-error properties

我一直遇到一个奇怪的错误,让我整个上午都挂了电话.我有一个Grails应用程序,其Person类看起来像这样:

class Person {
        String id
    Date   lastUpdated
    String note
    String lastName
    String firstName
    String middleName
    String facility
    ...
}
Run Code Online (Sandbox Code Playgroud)

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

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]
}
Run Code Online (Sandbox Code Playgroud)

现在,这段代码昨天工作正常.然而今天早上,没有做任何修改(我甚至尝试恢复到较旧的svn提交)当我单击g:链接以显示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)
Run Code Online (Sandbox Code Playgroud)

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

Bur*_*ith 9

尝试运行grails clean- 有时增量编译失败,因此强制完全编译通常会使像这样的奇怪问题消失.

  • 正确 - 在STS或其他IDE中清理项目只是清除其编译的类,但它们与Grails为run-app编译的类不同.因此,当run-app行为时,运行`grails clean`,当IDE很时髦时,清理项目. (2认同)