赞
踩
springboot集成security需要三步:
一、引入依赖
- <!--集成安全框架-->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-security</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-test</artifactId>
- </dependency>
- <!--thymeleaf整合security:依赖,旧版springboot不支持5版本,使用4版本集成安全框架-->
- <dependency>
- <groupId>org.thymeleaf.extras</groupId>
- <artifactId>thymeleaf-extras-springsecurity5</artifactId>
- <version>3.0.4.RELEASE</version>
- </dependency>
二、WebSecurityConfigurerAdapter抽象类得子类实现
具体实现类
- package com.offcn.pj.controller.page.config;
-
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
- import org.springframework.security.config.annotation.web.builders.HttpSecurity;
- import org.springframework.security.config.annotation.web.builders.WebSecurity;
- import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
- import org.springframework.security.core.user
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。