title: Java config for spring interceptor where interceptor is using autowired spring beans
body: <p>I want to add spring mvc interceptor as part of Java config. I already have a xml based config for this but I am trying to move to a Java config. For interceptors, I know that it can be done like this from the spring documentation-</p>
  
  <pre><code>@EnableWebMvc
  @Configuration
  public class WebConfig extends WebMvcConfigurerAdapter {
  
      @Override
      public void addInterceptors(InterceptorRegistry registry) {
          registry.addInterceptor(new LocaleInterceptor());
      }
  
  }
  </code></pre>
  
  <p>But my interceptor is using a spring bean autowired into it like follows-</p>
  
  <pre><code>public class LocaleInterceptor extends HandlerInterceptorAdaptor {
  
      @Autowired
      ISomeService someService;
  
      ...
  }
  </code></pre>
  
  <p>The SomeService class looks like follows-</p>
  
  <pre><code>@Service
  public class SomeService implements ISomeService {
  
     ...
  }
  </code></pre>
  
  <p>I am using annotations like <code>@Service</code> for scanning the beans and have not specified them in the configuration class as <code>@Bean</code></p>
  
  <p>As my understanding, since java config uses new for creating the object, spring will not automatically inject the dependencies into it. </p>
  
  <p>How can I add the interceptors like this as part of the java config?</p>