文章目录

前言

1:环境要求

2:技术要求

一:搭建SpringBoot环境

1:创建空项目

2:创建SpringBoot项目

3:编写一个简单的controller

二:整合SpringSecurity 

1:引入依赖

2:重新启动项目

3:之后再记访问hello接口


 

前言

1:环境要求

2:技术要求

一:搭建SpringBoot环境

1:创建空项目

SpringSecurity6从入门到上天系列第二篇:搭建SpringSecurity6的入门级别程序!-LMLPHP

        注意,对于JDK17这个版本,我们的idea版本需要对应到2023版本以上才行。 

SpringSecurity6从入门到上天系列第二篇:搭建SpringSecurity6的入门级别程序!-LMLPHP

SpringSecurity6从入门到上天系列第二篇:搭建SpringSecurity6的入门级别程序!-LMLPHP 

2:创建SpringBoot项目

SpringSecurity6从入门到上天系列第二篇:搭建SpringSecurity6的入门级别程序!-LMLPHP

3:编写一个简单的controller

@RestController
public class controller {

    @RequestMapping("hello")
    public String hello(){
        return "hello...";
    }
}

 

SpringSecurity6从入门到上天系列第二篇:搭建SpringSecurity6的入门级别程序!-LMLPHP

二:整合SpringSecurity 

1:引入依赖

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

2:重新启动项目

        从新启动项目的时候的启动日志

Using generated security password: c3fe63f0-3555-496d-91f6-9f45357fde6b

This generated password is for development use only. Your security configuration must be updated before running your application in production.

3:之后再记访问hello接口

SpringSecurity6从入门到上天系列第二篇:搭建SpringSecurity6的入门级别程序!-LMLPHP

        登录之后再进行具体的接口

SpringSecurity6从入门到上天系列第二篇:搭建SpringSecurity6的入门级别程序!-LMLPHP

三:上述测试完毕之后的几个问题

接下来的文章里边,我们会一一分享。

10-31 08:47