title: AuthenticationProcessingFilter and WebSecurityConfigurerAdapter causing circular dependency
body: <p>In my Spring boot app, I have the following two classes: </p>
  
  <pre><code>@EnableWebSecurity
  public class AppSecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Autowired
      private JwtAuthenticationFilter jwtAuthenticationFilter;
  
      @Bean
      @Override
      public AuthenticationManager authenticationManagerBean() throws Exception {
          return super.authenticationManagerBean();
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
          // TODO re-enable csrf after dev is done
          .csrf()
              .disable()
              // we must specify ordering for our custom filter, otherwise it
              // doesn't work
              .addFilterAfter(jwtAuthenticationFilter,
                      UsernamePasswordAuthenticationFilter.class)
              // we don't need Session, as we are using jwt instead. Sessions
              // are harder to scale and manage
              .sessionManagement()
              .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
     }
  }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>@Component
  public class JwtAuthenticationFilter extends
          AbstractAuthenticationProcessingFilter {
  
      /*
       * we must set authentication manager for our custom filter, otherwise it
       * errors out
       */
      @Override
      @Autowired
      public void setAuthenticationManager(
              AuthenticationManager authenticationManager) {
          super.setAuthenticationManager(authenticationManager);
      }
  }
  </code></pre>
  
  <p><code>JwtAuthenticationFilter</code> depends on an <code>AuthenticationManager</code> bean through its <code>setAuthenticationManager</code> method, but that bean gets created in <code>AppSecurityConfig</code> which has <code>JwtAuthenticationFilter</code> autowired in. This whole thing creates a circular dependency. 
  How should I resolve this issue?</p>