title: SpringBoot: @Validated and @PreDestroy Error creating bean with name 'defaultValidator'
body: <p>I have a Spring service with <code>@PreDestroy</code> method which calls another service</p>
  <pre><code>@Service
  public class DestroyMe {
    public final ValidService service;
    private SomeDto dto;
    @PreDestroy
      public void destroy() {
          service.stop(dto);
    }
  }
  </code></pre>
  <p>The <code>ValidService</code> its an interface with <code>@Validated</code> class level annotation</p>
  <pre><code>@Validated
  public interface ValidService {
    public void stop(@Valid SomeDto dto);
  }
  </code></pre>
  <p>Also there's implementation class of this interface (with <code>@Service</code> annotation).</p>
  <p>Validation works correctly in runtime, but when SprinBoot application terminates, it calls the <code>destroy</code> method which calls the <code>service.stop(dto)</code> and I get this error:</p>
  <p><code>Error creating bean with name 'defaultValidator': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)</code>.</p>
  <p>Clicking on <code>defaultValidator</code> in IDE brings me into <code>public static LocalValidatorFactoryBean defaultValidator()</code> of <code>ValidationAutoConfiguration</code> class.</p>
  <p>If I remove the <code>@Validated</code> annotation from the <code>ValidatedService</code> all works correctly but there's no service's input validation.
  Looks like Spring is trying to create the validator bean ad-hoc to validate the input to <code>stop</code> method but it's not possible to do this in destroy phase.</p>
  <p>How to solve this problem?</p>
  <p><strong>EDIT 1</strong>
  Here is the code to reproduce this behavior: <a href="https://github.com/smacz/predestroy" rel="nofollow noreferrer">https://github.com/smacz/predestroy</a></p>