我正在開發(fā)實(shí)現(xiàn) spring 安全性的簡(jiǎn)單項(xiàng)目。當(dāng)我嘗試使用Spring和Thymeleaf 的注銷鏈接時(shí),問(wèn)題就出現(xiàn)了。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>導(dǎo)航欄.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>錯(cuò)誤截圖:
1 回答

心有法竹
TA貢獻(xiàn)1866條經(jīng)驗(yàn) 獲得超5個(gè)贊
當(dāng) Thymeleaf Extras Spring Security 版本與 Spring Framework 版本不兼容時(shí)會(huì)發(fā)生此錯(cuò)誤,在這種情況下,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>
添加回答
舉報(bào)
0/150
提交
取消