문제
로그인, 로그아웃 같은 기능은 잘 동작하는데 Thymeleaf에서 Spring Security가 동작을 안 하는 현상이 발생했다.
dependencies 추가도 해줬는데 왜 안돼는 건가 싶었다.
시도
project clean을 해보고, 의존성을 삭제하고 gradle refresh하고 다시 추가하고 gradle refresh를 했다.
그래도 변함이 없었따.
해결
Spring Security 의존성을 1개만 추가했다.
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
이 의존성을 추가하지 않은 것이다..!! 완전 어이없는 실수..
잊지말자!
thymeleaf에서 spring security를 사용하기 위해서는 security 말고도 thymeleaf와 연관된 security 의존성을 추가해줘야한다.
- implementation 'org.springframework.boot:spring-boot-starter-security'
- implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'