修改build.gradle
// 添加 Spring Security依赖
implementation 'org.springframework.boot:spring-boot-starter-security'
// 添加 Thymeleaf Spring Security 依赖
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity4:3.0.2.RELEASE'
与Thymeleaf集成
gradle
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity'
Maven
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>