John__wang 2015-06-12 01:54
浏览 720

grails Domain属性名与GORM API方法名相 冲突

环境:win7 + intellij13 + grails2.2.3
一个已有项目有下面一个domain
class AxisType extends ScalarType {
...
String first
String last
...

static constraints = {
    ...
    first nullable: true
    last nullable: true
}

}
在项目启动时报下面的错误信息:

org.codehaus.groovy.grails.web.context.GrailsContextLoader Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: com.alu.ud.pm.common.AxisType.first() is applicable for argument types: () values: []

Possible solutions: first(), first(), first(), first(java.lang.String), first(java.util.Map), first(java.lang.String)

从错误信息上看,grails 把domain的属性first当成了GROM api里的first()方法来处理了,初步估计domain的属性名不能和GORM API方法名(如last, first, fistAll)重复。
但是在新建一个helloworld去验证这个问题的时候

class AxisType {
String first
String last
static constraints = {
first(nullable:true)
last(nullable:true)
}
}
helloworld工程启动成功,访问 anAxisTypeObject.first, AxisType.first()方法时都很正常,不会相互影响。

感觉问题好诡异,哪位大神能来给解释一下这是什么情况?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 lammps拉伸应力应变曲线分析
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题