当前位置:   article > 正文

spring boot 项目集成security_springboot集成security

springboot集成security

springboot集成security需要三步:

一、引入依赖

  1. <!--集成安全框架-->
  2. <dependency>
  3. <groupId>org.springframework.boot</groupId>
  4. <artifactId>spring-boot-starter-security</artifactId>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.springframework.security</groupId>
  8. <artifactId>spring-security-test</artifactId>
  9. </dependency>
  10. <!--thymeleaf整合security:依赖,旧版springboot不支持5版本,使用4版本集成安全框架-->
  11. <dependency>
  12. <groupId>org.thymeleaf.extras</groupId>
  13. <artifactId>thymeleaf-extras-springsecurity5</artifactId>
  14. <version>3.0.4.RELEASE</version>
  15. </dependency>

二、WebSecurityConfigurerAdapter抽象类得子类实现

 具体实现类

  1. package com.offcn.pj.controller.page.config;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  5. import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  6. import org.springframework.security.config.annotation.web.builders.WebSecurity;
  7. import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  8. import org.springframework.security.core.user
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/870209
推荐阅读
相关标签
  

闽ICP备14008679号