对于HeadersConfigurer <httpsecurity>类型,方法sessionManagement()未定义

时间:2017-06-22 06:44:50

标签: spring-boot spring-oauth2

我正在配置一个Spring Boot Oauth2项目,它被困在ResourceServerConfiguration类的configure方法中。

@Override
    public void configure(HttpSecurity http) throws Exception {

        http.exceptionHandling()
                .authenticationEntryPoint(customAuthenticationEntryPoint)
                .and()
                .logout()
                .logoutUrl("/oauth/logout")
                .logoutSuccessHandler(customLogoutSuccessHandler)
                .and()
                .csrf()
                .requireCsrfProtectionMatcher(
                        new AntPathRequestMatcher("/oauth/authorize"))
                .disable().headers().frameOptions().disable()
                .sessionManagement()
                .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                .and().authorizeRequests().antMatchers("/hello/")
                .permitAll().antMatchers("/secure/**").authenticated();

    }

在上面的代码中,虽然我已导入

import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.http.SessionCreationPolicy;

它在sessionManagement()中显示错误,表示

The method sessionManagement() is undefined for the type HeadersConfigurer<HttpSecurity>

任何想法/解决方案??

谢谢!!

1 个答案:

答案 0 :(得分:0)

使用最新的Spring Security版本4.2.3.RELEASE,您将不会遇到任何问题。您还应该重建项目。