目录
一、工程结构
二、配置文件
我的spring boot已经管理过了版本号,如果你没有管理版本号 自己再这个添加版本信息。
2.1 pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.3.5.RELEASE</version>
</dependency>
</dependencies>
2.2 application.yml
server:
port: 8083
三、源代码
3.1 在static文件夹下创建index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>我是主页面</h1>
</body>
</html>
3.2 启动类
@SpringBootApplication
@EnableWebSecurity
public class SpringSecurityApp {
public static void main(String[] args) {
SpringApplication.run(SpringSecurityApp.class, args);
}
}
四、启动测试
访问;localhost:8083
这个登录页面是Spring Security自动帮我们写好的。