Sample project using Spring Security 6. This project use following.
- Spring Security 6
- Spring Data JPA
- H2 database
- JUnit 5
I created this project for learning Spring Security 6, because recent Spring Security (5.x) has drastically changed security settings, and Spring Security 6 has further deprecated or removed more functions.
You can do the following in this project.
- Login
- Logout
- Show user account info
- Test spring security by JUnit.
This project use H2 Database in-memory mode. So you don't have to build database environment.
Make sure you have installed all of the following prerequisites on your development machine:
- Git - Download & Install Git. OSX and Linux machines typically have this already installed.
- Java - Download & Install Java and set JAVA_HOME.
You also have to build spring-boot running environment (Eclipse or VSCode) in advance.
- Click SpringSecuritySampleApplication.java
- Right click and run as Java Application
- Click SpringSecuritySampleApplication.java
- Right click and click Debug Java
You can access following page.
- Top page (http://localhost:8080/)
- Login page (http://localhost:8080/login)
- My page (http://localhost:8080/myPage)
Test spring security login authentication by JUnit.
- Click LoginTestEngVer.java
- Right click and run as JUnit Test
- Click LoginTestEngVer.java
- Right click and click running the current test file
👤 Naoki Nakanishi
- Website: https://n-laboratory.jp/nlab/
- Twitter: @N-LAB