Search code examples
springspring-mvcbean-validationhibernate-validator

How to configure Bean Validation with Spring MVC


I am trying to configure Spring : LocalValidatorFactoryBean to set my custom TraversableResolver

I do the following in my applicationContext.xml :

<bean id="customTraversableResolver" class="com.package.core.resolver.SimpleTraversableResolver" />

<bean id="validator"
    class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
    <property name="traversableResolver" ref="customTraversableResolver" />
</bean>

But at runtime, @Valid bean in controller are validated with default traversable resolver (from hibernate validator). So, how to configure default bean validation configuration in spring ?


Solution

  • Have you tried adding validation.xml and adding the traversable resolver configuration in there? Btw, what do you want to achieve with your custom resolver?