0

由于以下代码行,在运行单元测试时出现 MissingMethodException

class SystemNotification {
    static mapping = {
       read column: 'rd'
    }
    .
    .
}

这是生成的堆栈跟踪的相关位。

groovy.lang.MissingMethodException: No signature of method:
frontlinesms2.SystemNotification.read() is applicable for argument types: () values: []
Possible solutions: read(java.io.Serializable), load(java.io.Serializable), isRead(), create(), getId(), grep()
at frontlinesms2.SystemNotification._clinit__closure1(SystemNotification.groovy:6)

删除 read->rd 映射允许测试通过。关于不需要删除代码的解决此问题的任何想法?域类来自插件,如果相关的话。该插件使用 h2 作为独立应用程序运行,但主机应用程序使用 MySQL,其中“read”是保留关键字,这就是我们首先进行映射的原因。

4

1 回答 1

0

嗯,所以如果您想更改列名,那么您必须执行以下操作,目前您使用 read('x') 作为方法:

class SystemNotification {
    String read
    static mapping = {
       read column: 'rd'
    }
}

测试失败是正确的。

于 2013-09-12T14:41:36.520 回答