1新建springboot项目,并在pom.xml文件中加入spring 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>
<scope>test</scope>
</dependency>
2、直接启动springboot项目,会生成一段密码
3、打开浏览器,输入http://localhost:8080后回车,用户名为user,密码为刚才控制台生成的密码,登陆
在springboot中,只要加入了对spring security的依赖,直接启动spring boot项目便可运行spring security。
4、登陆后如图,由于没有跳转页面,显示404 not found,后续可以根据自己的需求编写界面,小案例到此结束。