-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Karthik Gurumurthy opened SPR-6377 and commented
javax.validation.Validator doesn't get injected with mvc:annotation-driven/
@Controller
class MyController{
@Autowired
private javax.validation.Validator validator;
}
stack trace >>>
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.validation.Validator com.etrade.af.account.controller.AccountController.validator; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.validation.Validator] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org
.springframework.beans.factory.annotation.Autowired(required=true)}
It works if I explicitly declare LocalValidatorFactoryBean in my application context though.
mvc:annotation-driven/
<!-- Explicitly Configure JSR-303 Declarative Validation -->
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
I guess the mvc namespacehandler doesn't register this class with the bean registry by default?
Affects: 3.0 RC2
Referenced from: commits 4efa91d