我试图执行验证像在Spring 3.0文档的部分5.7.4.3描述我的web应用程序:春JSR303验证不起作用像春天文档中描述
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="webBindingInitializer">
<bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="validator">
<bean class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
</property>
</bean>
</property>
</bean>
我添加的Hibernate验证作为依赖,一切看起来不错,但开始我在下面的错误的Web应用程序的结果:
org.springframework.beans.NotWritablePropertyException:
Invalid property 'validator' of bean class
[org.springframework.web.bind.support.ConfigurableWebBindingInitializer]:
Bean property 'validator' is not writable or has an invalid setter method.
Does the parameter type of the setter match the return type of the getter?
当看它是很明显,什么是错的API。 LocalValidatorFactoryBean
implements javax.validation.Validator
,而ConfigurableWebBindingInitializer.setValidator()
预计org.springframework.validation.Validator
。
任何解决方案?
编辑
This is the central class for
javax.validation
(JSR-303) setup in a Spring application context: It bootstraps ajavax.validation.ValidationFactory
and exposes it through the SpringValidator
interface as well as through the JSR-303Validator
interface and theValidatorFactory
interface itself.
像亚历克斯·马歇尔低于这个规定是不的情况。 LocalValidatorFactoryBean
只实现javax.validation.Validator
。
LocalValidatorFactoryBean
虽然延伸SpringValidatorAdapter
,它实现了org.springframework.validation.Validator
。
我也尝试更新到'hibernate-core-3.5.0.Beta-1',但Spring的Hibernate代码与此版本不兼容。 – Koraktor 2009-10-02 12:43:19
在http://jira.springframework.org/browse/SPR-6189上打开JIRA问题。 – Koraktor 2009-10-05 06:25:28