美好的一天,就我而言,一切都很好,并且可以在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>
没有错误或在启动时发出警告。请指教
答案 0 :(得分:0)
经过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();
}
谢谢