Spring Boot Security - java.lang.IllegalArgumentException: Cannot pass a null GrantedAuthority collection

前端 未结 1 680
轮回少年
轮回少年 2020-12-31 03:15

I am new to Spring boot and Spring Security. Is there any issues with my current Spring boot version 1.3.7.RELEASE? How can I fixed this problem?

My SecurityC

相关标签:
1条回答
  • 2020-12-31 03:38

    java.lang.IllegalArgumentException: Cannot pass a null GrantedAuthority collection

    The error is obvious, you should assign at least one role to your first user. For example, you can assign him a USER role too:

    @Configuration
    @EnableGlobalMethodSecurity(securedEnabled = true)
    public class SecurityConfig extends WebSecurityConfigurerAdapter {
        @Autowired
        public void configureAuth(AuthenticationManagerBuilder auth) throws Exception {
            auth
                .inMemoryAuthentication()
                    .withUser("thomas")
                    .password("password")
                    .roles("USER")
                .and()
                    .withUser("joe")
                    .password("password")
                    .roles("USER");
        }
    }
    
    0 讨论(0)
提交回复
热议问题