title: Spring Validator: Could not autowire. No beans of 'Validator' type found
body: <p>I don't know if I need to and some more code/details about this but I am ready to supply more info if needed :)</p>
  
  <p>I get: <code>Could not autowire. No beans of 'Validator' type found</code>. There are similar questions in here but there are not about <code>Validator</code>. I tried to autowire it via constructor but it is still same. I use Intellij Ultime edition. Latest version of <code>spring-boot-starter-xxx-xxx</code> which is 1.4.1.RELEASE at the moment.</p>
  
  <pre><code>@Configuration
  public class RestConfig extends RepositoryRestConfigurerAdapter {
  
      @Autowired
      private Validator validator;
  
      @Override
      public void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener validatingListener) {
          validatingListener.addValidator("beforeCreate", validator);
          validatingListener.addValidator("beforeSave", validator);
      }
  }
  </code></pre>
  
  <p>Edit:</p>
  
  <p>I changed my code to this and it worked. Thanks for answers..</p>
  
  <pre><code>@Bean
  public Validator validator() {
      return new LocalValidatorFactoryBean();
  }
  
  
  @Override
  public void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener validatingListener) {
      validatingListener.addValidator("beforeCreate", validator());
      validatingListener.addValidator("beforeSave", validator());
  }
  </code></pre>
  
  <p>By the way, I just wonder if the person who voted down this question can explain why he/she did that?</p>