https://spring.io/projects/spring-security#learn
Spring Security 6.1.0 버전 사용
dependency 추가 메뉴:
프로젝트 우클릭 -> Spring -> add Starters
Frequently Used 메뉴들 다 체크해서 추가해줘야 함.
Spring Security 추가.
Next >
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
testImplementation 'org.springframework.security:spring-security-test'
추가.
finish.
build.gradle
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
// Thymeleaf Layout Dialect 기능 사용:
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.2.1'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.oracle.database.jdbc:ojdbc11'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}
project -> gradle -> refresh gradle project 해주는게 좋음.
서버 재시작하면 콘솔에 비밀번호가 나옴.
서버 시작 할 때마다 달라짐.
주소에 들어가면 로그인 화면이 뜸.
id: user
password: 콜솔창에 있던 비밀번호
security 적용 후 접속 시에는 시크릿 창으로 들어가는 게 편함.