SpringBoot 整合SpringSecurity

1. pom.xml Maven依赖

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

2. 注解

  A. @EnableWebSecurity:开启Security服务,对于starter这类jar包,不需要手动开启,因为SpringBoot会通过autoconfigure自动来加载注入相关的security配置信息,自动配置类是SecurityAutoConfiguration;

  B. @EnableGlobalMethodSecurity:开启全局Securtiy注解。

3. 配置类

extends WebSecurityConfigurerAdapter类

posted @ 2021-03-09 20:38  如幻行云  阅读(75)  评论(0编辑  收藏  举报