I\'m trying pass filter JWTLoginFilter to WebSecurityConfig WebSecurityConfigurerAdapter by @Autowired annotation. The problem arise when JWTLoginFilter try get AuthenticationMa
Your WebSecurityConfig
explicitly requests JWTLoginFilter
to be injected in it, and JWTLoginFilter
requests AuthenticationManager
to be injected in its constructor. AuthenticationManager
is supplied by WebSecurityConfig
, so you have a circular dependency.
Remove @Component
annotation from JWTLoginFilter
and define the filter as a bean in WebSecurityConfig
:
@Bean
public JWTLoginFilter jwtLoginFilter() {
return new JWTLoginFilter("/login", authenticationManager());
}
You will probably also need to inject UserService
manually in this method (for example, via constructor).