在Grails中,是;不动产;保留字?
在Grails中,“属性”是保留字吗?也就是说,我可以命名一个域类在Grails中,是;不动产;保留字?,grails,Grails,在Grails中,“属性”是保留字吗?也就是说,我可以命名一个域类Property,并让其所有者通过properties引用它吗?例如: class Thing { static hasMany = [properties: Property] } class Property { static belongsTo = [thing: Thing] } 当我尝试将属性添加到对象时,会出现以下错误: Exception thrown: No signature of metho
Property
,并让其所有者通过properties
引用它吗?例如:
class Thing {
static hasMany = [properties: Property]
}
class Property {
static belongsTo = [thing: Thing]
}
当我尝试将属性
添加到对象
时,会出现以下错误:
Exception thrown: No signature of method: org.codehaus.groovy.grails.web.binding.DataBindingLazyMetaPropertyMap.add() is applicable for argument types: (Property) values: [Property : null]
groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.grails.web.binding.DataBindingLazyMetaPropertyMap.add() is applicable for argument types: (Property) values: [Property : null]
at ConsoleScript10.run(ConsoleScript10:3)
是否有所有Grails保留字的列表?虽然我不能,但明智的做法是不要使用这样一个常用字——谁知道将来什么时候它可能会被保留
如果你只是在类名前面加了一些东西,比如BlahProperty,会发生什么呢?我不确定
属性是否被保留,但是属性是专门为域类处理的,因为它用于。当你改变时会发生什么:
static hasMany = [properties: Property]
差不多
static hasMany = [myProperties: Property]
Grails是一个web框架。一般来说,只有语言才有保留字。Groovy的保留字都是Java保留的字,再加上一些其他字。将显示完整的列表
您会注意到它确实包含了“property”,这对我来说是一个很大的惊喜,因为我不知道它的用途,而且我认为/认为我对Groovy相当了解。也许是留作将来使用