title: Injecting a service in spring boot filter
body: <p>Have a filter where a service is autowired.
  I am injecting the service as constructor argument - from the config where filter is registered.</p>
  <pre><code>MyFilter implements Filter {
      private final ServiceToBeInjected serviceToBeInjected;
  
      public MyFilter(ServiceToBeInjected serviceToBeInjected) {
          this.serviceToBeInjected = serviceToBeInjected;
      }
  }
  
  public class ConfigClass {
      private final ServiceToBeInjected serviceToBeInjected;
  
      @Autowired
      public ConfigClass(ServiceToBeInjected serviceToBeInjected) {
          this.serviceToBeInjected = serviceToBeInjected;
      }
  
      @Bean
      public FilterRegistrationBean&lt;MyFilter&gt; filterRegistrationBean() {
          final FilterRegistrationBean&lt;MyFilter&gt; filterRegBean = new FilterRegistrationBean&lt;&gt;();
          filterRegBean.setFilter(new MyFilter(serviceToBeInjected));
          filterRegBean.addUrlPatterns(&quot;);    
          return filterRegBean;
      }
  }
  </code></pre>
  <p>I kind of felt autowiring from config might not be good.
  Is there any other better way ?</p>