Error creating bean with name 'springSecurityFilterChain'

后端 未结 2 410
星月不相逢
星月不相逢 2021-01-17 07:33

I have been following the Spring Security Reference and i added only this classes:

@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extend         


        
相关标签:
2条回答
  • 2021-01-17 07:59

    I had the same problem. I fixed it deleting http.antMatchers("").The problem was "" - SpringSecurityFilterChain throws an error, because pattern could not be empty or null.

    0 讨论(0)
  • 2021-01-17 08:01

    I copied your spring security configuration and was able to reproduce the error.

    Following line in the stacktrace gives the root cause of the exception:

    at org.springframework.security.provisioning.InMemoryUserDetailsManager.createUser(InMemoryUserDetailsManager.java:59)
    

    In InMemoryUserDetailsManager class, createUser() method, Spring checks if the user exists before creating an user. In your case you are adding two user with same username, hence there is an IllegalArgumentException.

    I added two users with different usernames and it started working fine.

    0 讨论(0)
提交回复
热议问题