- security定義
Spring Security 是一個提供身份驗證,授權和保護以防止常見攻擊的框架.憑藉對命令式和響應式應用程序的一流支持,他是用於保護基於Spring的應用程序的事實上的標準. - 使用先決條件
需要Java 8 或更高版本的運行環境 - 許可認證
Spring Security 是在 Apache 2.0許可下發行的開源軟件 - spring Securtity 的源碼地址
https://github.com/spring-projects/spring-security/ - maven 裏面的pom.xml 引入
SpringBoot 版
<dependencies>
<!-- ... other dependency elements ... -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
由於springboot提供了一個Maven BOM 來管理依賴版本,因此我們無需指定版本,如果可以更改版本
可以加上一下任意一種配置
<properties>
<!-- ... -->
<spring-security.version>5.3.0.RELEASE</spring-security.version>
</dependencies>
或者
<properties>
<!-- ... -->
<spring.version>5.2.4.RELEASE</spring.version>
</dependencies>
非SpringBoot版
當我們沒在springboot下面使用SpringSecurity時,首選方法是使用SpringSecurity的BO,以確保在整個項目中使用一致的SpringSecurity版本
<dependencyManagement>
<dependencies>
<!-- ... other dependency elements ... -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-bom</artifactId>
<version>{spring-security-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
- SpringSecurity的特點
SpringSecurity 爲身份驗證,授權和針對常見漏洞的防護提供了全面的支持.他還提供與其他庫的集成,以簡化其應用.