美文网首页
SpringBoot2x版本整合Spring Security中

SpringBoot2x版本整合Spring Security中

作者: 周山 | 来源:发表于2020-08-16 20:59 被阅读0次

问题描述:

使用springboot2版本整合SpringSecurity过程中,发现sec:这个标签无效,导致无法实现权限控制前台标签。

解决思路:

查看是否是版本问题,首先查看pom.xml文件,2.1.x版本后已经改成springsecurity5的名称空间了。

解决办法:

1、maven重新导入相关依赖 thymeleaf-extras-springsecurity5

      <properties>
...
    <thymeleaf-extras-springsecurity.version>3.0.4.RELEASE</thymeleaf-extras-springsecurity.version>
...
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-springsecurity5</artifactId>
    </dependency>

2、更改html名称空间

 <html xmlns:th="http://www.thymeleaf.org"
  xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity">

解决问题!

相关文章

网友评论

      本文标题:SpringBoot2x版本整合Spring Security中

      本文链接:https://www.haomeiwen.com/subject/unsxjktx.html