How to use hasRole in Spring Security?
问题 I wrote SpringBoot application with authentication via web login form. Class WebSecurityController is responsible for authentication and authorization. Here is its code: @Controller @EnableWebSecurity public class WebSecurityController extends WebSecurityConfiguration { @Autowired DataSource dataSource; protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers("/users/getAll").access("hasRole('ROLE_ADMIN')") .anyRequest().permitAll() .and()