1. 程式人生 > 其它 >第六章、SpringBoot整合SpringSecurity

第六章、SpringBoot整合SpringSecurity

技術標籤:SpringBoot部落格-前後端

下面是一個簡單的登入測試案例

專案結構大致如下,裡面部分內容與上一篇部落格相同

pom.xml需要新增兩個jar包

<!-- Spring Security -->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<!--對Thymeleaf新增Spring Security標籤支援-->
<dependency>
	<groupId>org.thymeleaf.extras</groupId>
	<artifactId>thymeleaf-extras-springsecurity4</artifactId>
	<version>3.0.2.RELEASE</version>
</dependency>

配置檔案application.properties 如下

####  thymeleaf配置   #######
spring.thymeleaf.mode=HTML5
# 編碼
spring.thymeleaf.encoding=UTF-8
# 型別
spring.thymeleaf.content-type=text/html
# 開發時關閉快取,不然沒法看到實時頁面
spring.thymeleaf.cache=false
# 預設路徑
spring.thymeleaf.prefix=classpath:/templates/
# 字尾
spring.thymeleaf.su