将我的依赖项和项目更新到了最新版本的Spring Boot 2.1.1,突然间,安全标签不起作用。我正在用Thymeleaf。
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
...
</dependencies>
我的HTML:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div sec:authorize="isAuthenticated()"> <!-- Doesn't work -->
...
</div>
</body>
</html>
答案 0 :(得分:0)
Thymeleaf的Spring Security Extras模块的依赖性管理和自动配置已从thymeleaf-extras-springsecurity4切换为thymeleaf-extras-springsecurity5。如果您使用的是模块,则应更新pom.xml或build.gradle以依赖thymeleaf-extras-springsecurity5。
因此,更新后的pom.xml应该更改以下依赖项:
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>`
收件人:
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>