无法找到EnableOAuth2Sso注释的导入

时间:2018-04-12 13:46:02

标签: java spring spring-security spring-security-oauth2

我尝试重复以下教程:

http://www.baeldung.com/sso-spring-security-oauth2

我有以下依赖项:

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    compile('org.springframework.boot:spring-boot-starter-security')
    compile("org.springframework.security.oauth:spring-security-oauth2:2.3.2.RELEASE")
    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity4:2.1.2.RELEASE')
}

我有以下课程:

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

    @Configuration
    @EnableOAuth2Sso
    public class UiSecurityConfig extends WebSecurityConfigurerAdapter {

        @Override
        public void configure(HttpSecurity http) throws Exception {
            http.antMatcher("/**")
                    .authorizeRequests()
                    .antMatchers("/", "/login**")
                    .permitAll()
                    .anyRequest()
                    .authenticated();
        }
    }

正如您所见,我没有导入@EnableOAuth2Sso注释。而Idea并不建议我导入自动完成功能。

我错了什么?

1 个答案:

答案 0 :(得分:2)

我替换了

 compile("org.springframework.security.oauth:spring-security-oauth2:2.3.2.RELEASE")

compile ("org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.0.0.RELEASE")

和Idea找到了导入