更新的依赖项和 Thymeleaf 标签不起作用 [英] Updated dependencies and Thymeleaf tags don't work

查看:95
本文介绍了更新的依赖项和 Thymeleaf 标签不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我的依赖项和项目更新到最新版本的 Spring Boot 2.1.1,突然安全标签不起作用.我正在使用 Thymeleaf.

pom.xml

<groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.1.RELEASE</version></父母><依赖项><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>2.1.1.RELEASE</version></依赖><依赖><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId><version>2.1.1.RELEASE</version></依赖><依赖><groupId>org.thymeleaf.extras</groupId><artifactId>thymeleaf-extras-springsecurity4</artifactId><version>3.0.4.RELEASE</version></依赖>...</依赖项>

我的 HTML:

<html xmlns="http://www.w3.org/1999/xhtml"xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"><头><title></title><身体><div sec:authorize="isAuthenticated()"><!-- 不起作用-->...

</html>

解决方案

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes#thymeleaf-spring-security-extras

<块引用>

Thymeleaf 的 Spring Security Extras 模块的依赖管理和自动配置已从 thymeleaf-extras-springsecurity4 切换到 thymeleaf-extras-springsecurity5.如果您正在使用该模块,则应更新 pom.xml 或 build.gradle 以依赖 thymeleaf-extras-springsecurity5.

所以更新后的 pom.xml 应该改变以下依赖:

<依赖><groupId>org.thymeleaf.extras</groupId><artifactId>thymeleaf-extras-springsecurity4</artifactId><version>3.0.4.RELEASE</version></依赖>`

到:

<依赖><groupId>org.thymeleaf.extras</groupId><artifactId>thymeleaf-extras-springsecurity5</artifactId><version>3.0.4.RELEASE</version></依赖>

Updated my dependencies and project to Spring Boot 2.1.1 which is the latest version and suddenly security tags don't work. I'm using 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>

My 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>

解决方案

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes#thymeleaf-spring-security-extras

Dependency management and auto-configuration for Thymeleaf’s Spring Security Extras module has switched from thymeleaf-extras-springsecurity4 to thymeleaf-extras-springsecurity5. If you were using the module, you should update your pom.xml or build.gradle to depend upon thymeleaf-extras-springsecurity5.

So the updated pom.xml should change the following dependency from:

<dependency>
     <groupId>org.thymeleaf.extras</groupId>
     <artifactId>thymeleaf-extras-springsecurity4</artifactId>
     <version>3.0.4.RELEASE</version>
</dependency>`

to:

<dependency>
     <groupId>org.thymeleaf.extras</groupId>
     <artifactId>thymeleaf-extras-springsecurity5</artifactId>
     <version>3.0.4.RELEASE</version>
</dependency>

这篇关于更新的依赖项和 Thymeleaf 标签不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆