我正在開發實現 spring 安全性的簡單項目。當我嘗試使用Spring和Thymeleaf 的注銷鏈接時,問題就出現了。1.pom.xml <!--Spring Boot Dependencies - Security --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <!-- Dependencies Spring Security--> <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-springsecurity4</artifactId> <version>2.1.2.RELEASE</version> <scope>compile</scope> </dependency>導航欄.html<ul class="nav navbar-nav navbar-right"> <!--<li><a th:href="@{/login}" th:text="#{navbar.login.text}"></a></li>--> <li th:if="${#authorization.expression('isAuthenticated()')}"> <a th:href="@{/login}" th:text="#{navbar.login.text}"/> </li> <li th:if="${#authorization.expression('isAuthenticated()')}"> <form id="f" th:action="@{/logout}" method="post" role="form" class="navbar-form"> <button type="submit" th:text="#{navbar.logout.text}" class="btn btn-primary"/> </form> </li> </ul>錯誤截圖:
1 回答

心有法竹
TA貢獻1866條經驗 獲得超5個贊
當 Thymeleaf Extras Spring Security 版本與 Spring Framework 版本不兼容時會發生此錯誤,在這種情況下,Spring Boot 版本適用于 Spring Framework 5.x 版,而您擁有的 Thymeleaf Extras Spring Security 版本是 4.x。您需要更新 pom.xml 中的 artifactId 并選擇兼容版本或讓 Spring Boot 為您選擇版本
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
<scope>compile</scope>
</dependency>
添加回答
舉報
0/150
提交
取消