This repository contains a Sprint Boot project that defines an API server using Java and Gradle. You'll secure this API with Auth0 to practice making secure API calls from a client application.
You can start the server in a terminal using the command:
./gradlew bootRun
It's also possible to start the server using Spring Tools and the IDE of your preference (VSCode, Eclipse, etc.)
This section adds helpful tips and information for development and contribution to this repository.
Gradle manages all dependencies along with their versions, which are locked so we can ensure reproducible builds. If you need to include another dependency or plugin, you can always add them to the build.gradle
file. Then you'll need to run the following command to update the lock files:
./gradlew dependencies --write-locks
The check task will run both Checkstyle
and Sonarlint
tasks for the main and test sources. You can run the check task with the command:
./gradlew check
Spring Boot offers a great way to live reload the code as you change it. This feature is called Hot Swapping, which is shipped with the spring-boot-devtools dependency.
Hot Swapping can be used mainly in 2 ways:
- Using Spring Tools and the IDE of your choice. Spring Tools will handle watching the files, recompiling, and restarting the server for you.
- Using the Gradle Wrapper and your favorite terminal. One terminal to watch and recompile, another to run the server.
Option (1) is usually more straightforward if you already have Spring Tools installed, just run the server from your IDE and Hot Swapping should be enabled. However, if you prefer option (2) you just need to follow two simple steps:
Open a terminal to watch/compile the project:
./gradlew compileJava -t
Open a second terminal to start the server:
./gradlew bootRun
And that's it! With both terminals running those Gradle tasks, Hot Swapping should work and the server will automatically restart when you change something in the code.