1
沒有什麼特別的情況,我相信它只是在最近纔開始發生試過grails clean
尚未擺脫了問題:grails 3.1.10自定義驗證器問題沒有這個。定義
域類:
static constraints = {
someThing(nullable:true, validator: this.checkSomething)
}
static def checkSomething= { val, obj, errors ->
if (val && obj.something?.findAll()?.size()>2 {
errors.rejectValue("something.error", [''] as Object[], '')
}
}
沒有this.
以下錯誤。有了this.staticMethod ide抱怨說這不是必需的。這是對的,我不應該需要它。只是想知道爲什麼奇怪的場景
錯誤引起的:
Caused by: groovy.lang.MissingPropertyException: No such property: checkSomething for class: org.grails.orm.hibernate.cfg.HibernateMappingBuilder
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
at com.example$__clinit__closure1.doCall(MyClass.groovy:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
at groovy.lang.Closure.call(Closure.java:426)
at com.example$__clinit__closure1.call(MyClass.groovy)
at groovy.lang.Closure.call(Closure.java:442)
at com.example$__clinit__closure1.call(MyClass.groovy)
at org.grails.orm.hibernate.cfg.HibernateMappingBuilder.evaluate(HibernateMappingBuilder.groovy:81)
at org.grails.orm.hibernate.cfg.HibernateMappingBuilder.evaluate(HibernateMappingBuilder.groovy)
at org.grails.datastore.mapping.config.AbstractGormMappingFactory.evaluateWithContext(AbstractGormMappingFactory.java:96)
at org.grails.datastore.mapping.config.AbstractGormMappingFactory.createMappedForm(AbstractGormMappingFactory.java:84)
at org.grails.orm.hibernate.cfg.HibernatePersistentEntity$1.<init>(HibernatePersistentEntity.java:41)
at org.grails.orm.hibernate.cfg.HibernatePersistentEntity.<init>(HibernatePersistentEntity.java:40)
at org.grails.orm.hibernate.cfg.HibernateMappingContext.createPersistentEntity(HibernateMappingContext.java:104)
at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntities(AbstractMappingContext.java:184)
at org.grails.orm.hibernate.cfg.HibernateMappingContext.<init>(HibernateMappingContext.java:55)
at org.grails.orm.hibernate.support.HibernateMappingContextFactoryBean.getObject(HibernateMappingContextFactoryBean.groovy:34)
at org.grails.orm.hibernate.support.HibernateMappingContextFactoryBean.getObject(HibernateMappingContextFactoryBean.groovy)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
... 63 common frames omitted