Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<mvc:annotation-driven> does not register javax.validation.Valdiator by default with the application context ? [SPR-6377] #11044

Closed
spring-projects-issues opened this issue Nov 17, 2009 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues
Copy link
Collaborator Author

Karthik Gurumurthy commented

I guess the mvc namespacehandler doesn't register this class with the bean registry by default?
I meant top level bean that is visible to others.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Good point: We're now exposing the default LocalValidatorFactoryBean as well as the default FormattingConversionServiceFactoryBean as top-level beans - with generated names but nevertheless accessible by type.

Juergen

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 RC3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants