springboot启动报错(webSecurity匿名问题)
springboot启动报错(webSecurity匿名问题)
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘springSecurityFilterChain’ defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method ‘springSecurityFilterChain’ threw exception; nested exception is java.lang.IllegalStateException: An incomplete mapping was found for []. Try completing it with something like requestUrls()..hasRole(‘USER’) |
在WebSecurityConfig(SecurityConfig)中配置
http.authorizeRequests() |
方法一: antMatchers(getAnonymousUrls()).anonymous(); 和anyRequest().authenticated(); 同时有
方法二: antMatchers(getAnonymousUrls()).anonymous(); 和至少用一个方法上有@AnonymousAccess注解
此文章版权归Chankeitin所有,如有转载,请註明来自原作者