Reputation: 243
I'm following this tutorial in order to validate my form, but since I'm using spring boot I wanted to avoid the mvc-dispatcher-servlet.xml file.
So instead of inserting it in the project I wrote a bean in my @Configuration class, obtaining this message:
Field validator in my.package.controller.MyController required a bean of type 'org.springframework.validation.Validator' that could not be found.
- Bean method 'resourceServerProperties' not loaded because @ConditionalOnClass did not find required class 'org.springframework.security.oauth2.common.OAuth2AccessToken'
I have tried both those beans:
@Bean
public Validator validator() {
return new org.springframework.validation.beanvalidation.LocalValidatorFactoryBean();
}
@Bean
public javax.validation.Validator localValidatorFactoryBean() {
return new LocalValidatorFactoryBean();
}
with the same result. What I'm doing wrong?
Upvotes: 0
Views: 485
Reputation: 207
You could specify the OrderValidator as a @Component
which implements org.springframework.validation.Validator
, so the Validator implementation can be found and injected.
Upvotes: 2