环境: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()方法时都很正常,不会相互影响。
感觉问题好诡异,哪位大神能来给解释一下这是什么情况?