実現したいこと
- WebSecurityConfigurerAdapterをimportする
前提
Spring Securityを使用して
クラスを作成する際に、WebSecurityConfigurerAdapterを上手く継承できなくて困ってます。
発生している問題・エラーメッセージ
WebSecurityConfigurerAdapterがうまく反映されない
該当のソースコード
Java
1package com.example.twitter.config; 2 3import org.springframework.context.annotation.Bean; 4import org.springframework.context.annotation.Configuration; 5import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 6import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 7 8@Configuration 9@EnableWebSecurity 10public class WebSecurityConfig extends WebSecurityConfigurerAdapter{ 11 12 @Bean 13 public BCryptPasswordEncoder passwordEncoder() { 14 // パスワードの暗号化用に、bcrypt(ビー・クリプト)を使用します 15 return new BCryptPasswordEncoder(); 16 } 17} 18
build.gradle
1plugins { 2 id 'java' 3 id 'org.springframework.boot' version '3.1.1' 4 id 'io.spring.dependency-management' version '1.1.0' 5} 6 7group = 'com.example' 8version = '0.0.1-SNAPSHOT' 9 10java { 11 sourceCompatibility = '17' 12} 13 14configurations { 15 compileOnly { 16 extendsFrom annotationProcessor 17 } 18} 19 20repositories { 21 mavenCentral() 22} 23 24dependencies { 25 implementation 'org.springframework.boot:spring-boot-starter-web' 26 compileOnly 'org.projectlombok:lombok' 27 annotationProcessor 'org.projectlombok:lombok' 28 testImplementation 'org.springframework.boot:spring-boot-starter-test' 29 implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' 30 implementation 'org.springframework.boot:spring-boot-starter-jdbc' 31 runtimeOnly 'com.mysql:mysql-connector-j' 32 implementation 'org.springframework.boot:spring-boot-starter-data-jpa' 33 implementation "org.springframework.boot:spring-boot-starter-security" 34 testImplementation 'org.springframework.security:spring-security-test' 35 developmentOnly 'org.springframework.boot:spring-boot-devtools' 36 implementation("org.springframework.session:spring-session-data-redis") 37} 38 39tasks.named('test') { 40 useJUnitPlatform() 41} 42
試したこと
・キャッシュの破棄
・import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;の追加
補足情報(FW/ツールのバージョンなど)

回答1件
あなたの回答
tips
プレビュー