spring bootを利用したfacebook oauth2認証ログインができません.
spring bootにてoauth2認証を行おうとしています.
ですが, [@EnableOAuth2Sso]アノテーションを利用するためのパッケージをimportしようとすると, どうしても「存在しません」, というエラーになってしまいます.
build.gradleにて
implementation 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.0.1.RELEASE'
を宣言しているのですが, できません.
どこからどのようにimportすれば良いでしょうか.
ちなみに, このパッケージをimplementationした時点ではエラーは発生しません.
build.gradle
java
1plugins { 2 id 'org.springframework.boot' version '2.1.6.RELEASE' 3 id 'java' 4} 5 6apply plugin: 'io.spring.dependency-management' 7 8group = 'com.teamlab' 9version = '0.0.1-SNAPSHOT' 10sourceCompatibility = '1.8' 11 12configurations { 13 developmentOnly 14 runtimeClasspath { 15 extendsFrom developmentOnly 16 } 17} 18 19repositories { 20 mavenCentral() 21} 22 23dependencies { 24 implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 25 implementation 'org.springframework.boot:spring-boot-starter-security' 26 implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' 27 implementation 'org.springframework.boot:spring-boot-starter-web' 28 implementation 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.0.1.RELEASE' 29 developmentOnly 'org.springframework.boot:spring-boot-devtools' 30 runtimeOnly 'com.h2database:h2' 31 runtimeOnly 'mysql:mysql-connector-java' 32 testImplementation 'org.springframework.boot:spring-boot-starter-test' 33 testImplementation 'org.springframework.security:spring-security-test' 34}
OauthController.java
java
1package com.teamlab.OAuthApplication.controller; 2 3import org.springframework.boot.autoconfigure.SpringBootApplication; 4import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 5import org.springframework.stereotype.Controller; 6import org.springframework.web.bind.annotation.GetMapping; 7import org.springframework.web.bind.annotation.RequestMapping; 8import org.springframework.web.bind.annotation.RequestMethod; 9import org.springframework.boot.autoconfigure.security.oauth2.client.*; 10import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso; //←ここがimportできませんとなります. 11 12@Controller 13@SpringBootApplication 14@EnableOAuth2Sso //importができないため, このアノテーションも使用できません. 15public class OauthController { 16 17 @RequestMapping(value = "/login", method = RequestMethod.GET) 18 public String login() { 19 return "login"; 20 } 21 22 @RequestMapping(value = "/user", method = RequestMethod.GET) 23 public String user() { 24 return "user"; 25 } 26 27 @RequestMapping(value = "/error", method = RequestMethod.GET) 28 public String error() { 29 return "error"; 30 } 31}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。