Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 非法状态例外:Can';在任何请求之后都不能配置antMatchers_Spring_Spring Boot_Spring Security_Spring Security Oauth2 - Fatal编程技术网

Spring 非法状态例外:Can';在任何请求之后都不能配置antMatchers

Spring 非法状态例外:Can';在任何请求之后都不能配置antMatchers,spring,spring-boot,spring-security,spring-security-oauth2,Spring,Spring Boot,Spring Security,Spring Security Oauth2,我想将Spring云安全OAuth2配置为应用不同的权限: /oauth/token-应应用httpBasic /oauth/revoke-不应应用httpBasic 我试过这个: http .csrf() .disable() .authorizeRequests() .anyRequest().authenticated() .and(

我想将Spring云安全OAuth2配置为应用不同的权限:

/oauth/token
-应应用httpBasic

/oauth/revoke
-不应应用httpBasic

我试过这个:

           http
            .csrf()
            .disable()
            .authorizeRequests()
                .anyRequest().authenticated()
                .and()
            // Configure token authentication permissions
            .requestMatchers().antMatchers(HttpMethod.POST,"/oauth/token")
                .and()
            // Configure token revoke permissions
            .authorizeRequests().antMatchers(HttpMethod.POST,"/oauth/revoke").permitAll()
                .and()
            .httpBasic()
                .and()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
当我运行代码时,我得到一个错误:

原因:org.springframework.beans.beans实例化异常:未能实例化[javax.servlet.Filter]:工厂方法“springSecurityFilterChain”引发异常;嵌套异常为java.lang.IllegalStateException:无法在任何请求后配置antMatchers

您知道如何正确应用此配置吗?

“无法在任何请求之后配置antMatchers” 您好,请尝试将antMatchers放在任何请求之前

我收到“错误描述”:“访问此资源需要完全身份验证”`