首页 > 解决方案 > 创建名为 'springSecurityFilterChain' 的 bean 时出错。不完整的映射。尝试使用 requestUrls() 完成它。.hasRole('用户')

问题描述

我有一个问题,我想标记我的所有身份验证。在扩展 WebSecurityConfigurerAdapter 的类 t 中,我以这种方式覆盖方法配置

 @Override
    protected void configure(final HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .requestMatchers(RequestMatcherResolver.getRequestMatchers())
                .authenticated()
                .and()
                .exceptionHandling()
                .authenticationEntryPoint(resolveExceptionEntryPoint);
    }

但我得到了一个远征:

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: 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().<something>.hasRole('USER')
Caused by: 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().<something>.hasRole('USER')
Caused by: java.lang.IllegalStateException: An incomplete mapping was found for []. Try completing it with something like requestUrls().<something>.hasRole('USER')

有谁能够帮我?

标签: javaspringsecurityservletsspring-security

解决方案


推荐阅读