从grails 1.3.7升级到2.0.1后,在控制器中验证命令对象时,我遇到了一些奇怪的异常。
groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method org.codehaus.groovy.grails.orm.hibernate.HibernateGormValidationApi#validate.
Cannot resolve which method to invoke for [class at.pdts.etsweb.commandobject.UserCommand, null] due to overlapping prototypes between:
[class java.lang.Object, interface java.util.List]
[class java.lang.Object, interface java.util.Map]
at org.grails.datastore.gorm.InstanceMethodInvokingClosure.call(GormEnhancer.groovy:251)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
我的UserCommand命令对象如下所示:
package at.pdts.etsweb.commandobject
import at.pdts.etsweb.Common
import grails.validation.Validateable
@Validateable
class UserCommand {
String username
String password
String firstname
String lastname
static constraints = {
username blank: false, email: true
password blank: false, minSize: 8, maxSize: 64, validator: Common.passwordValidator
firstname blank: false
lastname blank: false
}
}
控制器按如下方式绑定数据:
def save { UserCommand command ->
...
}
此时我收到上述错误消息。我还尝试使用命令对象作为参数save(UserCommand命令),但没有任何效果。有人有提示吗?
答案 0 :(得分:2)
我的解决方法是将命令对象类从/ grails-app / controller移动到/ src / groovy。之后,错误消失了。