gpt4 book ai didi

linux - Thymeleaf sec :authorize and sec:authentication attributes, 对生产没有影响,但在 IDE 上工作正常

转载 作者:太空宇宙 更新时间:2023-11-04 11:54:14 26 4
gpt4 key购买 nike

美好的一天,就我而言,一切都很好,并且在 localhost ide 上运行良好,但在 linux thymeleaf 下的站点上 sec:authorize 和 sec:authentication 属性未生效。

   <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
<version>3.0.11.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
<!-- marked the embedded servlet container as provided -->

这是 HTML

<li sec:authorize="isAnonymous()"><a class="inner-link" href="/login" title="Login">Login</a></li>
<li sec:authorize="isAuthenticated()"><a class="inner-link" th:href="@{/profile}" title="Profile">Profile</a></li>

启动时没有错误或警告。请指教

最佳答案

经过 4 天的努力,我已经启动了本地机器和 linux 服务器使用此配置:pom.xml

        <artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
<!-- marked the embedded servlet container as provided -->

它不适用于父版本 3 或更高版本,也不适用于 v 1.5 及以下版本。在 SecurityConfig 中我添加了一个 bean

 @Bean
public SpringSecurityDialect securityDialect() {
return new SpringSecurityDialect();
}

谢谢

关于linux - Thymeleaf sec :authorize and sec:authentication attributes, 对生产没有影响,但在 IDE 上工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54956768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com