https://blog.csdn.net/wssc63262/article/details/86011939
頁面無法讀取到sec:authorize="isAnonymous()"和sec:authorize="isAuthenticated()"甚至sec標籤頁不做解析。
把thymeleaf-extras-springsecurity4改爲thymeleaf-extras-springsecurity5即可
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity4 -->
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
/**定義認證規則*/
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//super.configure(auth);
auth.inMemoryAuthentication()
.withUser("admin").password(passwordEncoder().encode("admin")).roles("VIP1", "VIP2");
}