Tech Stack · Java
Spring Boot
Opinionated framework for production-ready Java services with almost no setup.
What it is
Spring Boot builds on the Spring Framework with starters (curated dependency sets), auto-configuration (sensible defaults based on what is on the classpath), and an embedded server, so a service runs with java -jar.
Create a project
Generate one at start.spring.io (choose Java, Gradle or Maven, and dependencies such as Spring Web), or from the terminal:
curl https://start.spring.io/starter.zip \
-d dependencies=web,actuator -d type=gradle-project -d name=demo -o demo.zip
Everyday commands
| Gradle | Maven | What it does |
|---|---|---|
./gradlew bootRun |
./mvnw spring-boot:run |
Run the app |
./gradlew test |
./mvnw test |
Run tests |
./gradlew bootJar |
./mvnw package |
Build an executable jar |
./gradlew bootBuildImage |
./mvnw spring-boot:build-image |
Build an OCI/Docker image |
java -jar build/libs/demo-0.0.1-SNAPSHOT.jar --server.port=9090
Key annotations
| Annotation | Purpose |
|---|---|
@SpringBootApplication |
Main class: enables auto-configuration and component scanning |
@RestController, @GetMapping |
HTTP endpoints that return JSON |
@Service, @Repository, @Component |
Beans picked up by component scanning |
@ConfigurationProperties |
Bind application.yml values to a typed class |