Adding Spring Security to our project
Before we can do anything with Spring Security, we must add it to our project.
To add Spring Security to our already drafted app, we can easily use the same tactic from the previous chapters:
- Visit start.spring.io.
- Enter the same project artifact details as before.
- Click on DEPENDENCIES.
- Select Spring Security.
- Click on EXPLORE.
- Look for the
pom.xml
file and click on it. - Copy the new bits onto the clipboard. Watch out! Spring Security has both a starter as well as a test module.
- Open up our previous project inside our IDE.
- Open our
pom.xml
file and paste the new bits into the right places.
Hit the refresh button in the IDE, and we’re ready to go!
Out of the box, we can run the application we have built up to this point. The exact same web app backed by Spring Data JPA is runnable…and it will be locked down.
Kind of.
When Spring Boot detects Spring Security on the path, it...