我正在按照此链接上的说明进行操作,该说明建议我更新我的引导 groovy 类。
// Bootstrap.groovy
import grails.converters.JSON
class BootStrap {
def init = { servletContext ->
JSON.registerObjectMarshaller(UserMapping) {
def rA = [:]
ra['userId'] = it.id
}
}
def destroy = {
}
}
但它返回错误:
ERROR context.GrailsContextLoader - Error initializing the application: No such property: UserMapping for class: BootStrap
Message: No such property: UserMapping for class: BootStrap
我的域类看起来像:
# UserMapping.groovy
package engagementlevels
class UserMapping {
String username
String email
Date insertTime
String type
String flags
static belongsTo = [groupMapping: GroupMapping]
static mapping = {
// Custom Mappings here
}
static hibernateFilters = {
// Filters here
}
transient beforeInsert = {
throw new RuntimeException('create not allowed')
}
transient beforeUpdate = {
throw new RuntimeException('update not allowed')
}
transient beforeDelete = {
throw new RuntimeException('delete not allowed')
}
}