Getting Started with Spring Boot
Learn how to set up and configure a Spring Boot application.
Content
Setting Up Development Environment
Versions:
Watch & Learn
AI-discovered learning video
Setting Up Spring Boot Development Environment (Without Summoning Chaos)
You already met Spring and Spring Boot. You get the vibe: conventions, auto-config, less XML, more happy. Now we turn theory into velocity by building a Spring Boot development environment that does not implode at the first curl request.
If microservices are a team sport, your machine is the gym. A consistent, repeatable Spring Boot development environment is how you go from 'works on my machine' energy to 'works on any machine' serenity. Today: tools, versions, the one JDK to rule them all, and a tiny app to prove it actually runs.
What Is a Spring Boot Development Environment?
A Spring Boot development environment is the curated combo of tools and settings that let you:
- Write code (IDE + Java)
- Build code (Maven or Gradle)
- Run code (Spring Boot + DevTools)
- Test and poke it (HTTP clients)
- Connect to stuff (databases, message brokers)
- Containerize it (Docker), because microservices will head to containers sooner than you can say dependency hell
Core ingredients:
- JDK: Use an LTS. Java 17 or 21 are your best friends.
- Build tool: Maven or Gradle. Use the wrapper to avoid version drama.
- IDE: IntelliJ IDEA, VS Code (with extensions), or Spring Tools Suite (Eclipse-based).
- Package/runtime helpers: SDKMAN!, Homebrew/Chocolatey/Winget.
- Docker: For databases and eventually your services.
- HTTP client: curl, HTTPie, Postman, or IntelliJ HTTP files.
Your north star: reproducibility. If you cannot reconstruct your setup in 30 minutes on a fresh laptop, future-you will invoice present-you.
How to Set Up Spring Boot Development Environment
We will go from zero to a running Spring Boot app with a hello endpoint and a local database in Docker. Choose commands for your OS.
1) Install Java (LTS)
- Recommended: Java 17 or Java 21 (Temurin/Adoptium is great).
macOS/Linux via SDKMAN!:
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 21-tem
sdk use java 21-tem
java -version
Windows (PowerShell, winget or Chocolatey):
winget install EclipseAdoptium.Temurin.21.JDK
# Or Chocolatey:
choco install temurin21
java -version
Set JAVA_HOME if needed:
macOS:
export JAVA_HOME=$(/usr/libexec/java_home -v 21)
Windows (PowerShell):
[Environment]::SetEnvironmentVariable('JAVA_HOME','C:\Program Files\Eclipse Adoptium\jdk-21','User')
$env:PATH = "$env:JAVA_HOME\bin;" + $env:PATH
2) Pick an IDE
| IDE | Why you might love it | Notes |
|---|---|---|
| IntelliJ IDEA (Community or Ultimate) | Spring magic, refactors that feel like wizardry | Ultimate has deep Spring features |
| VS Code + Extensions | Lightweight, fast, great for polyglot devs | Install Spring Boot + Java pack |
| Spring Tools Suite (Eclipse) | Spring-flavored Eclipse | Familiar for Eclipse folks |
3) Build Tool: Maven or Gradle
| Tool | Strengths | Gotchas |
|---|---|---|
| Maven | Convention first, predictable, verbose but clear | XML fatigue |
| Gradle | Concise, fast incremental builds, Kotlin DSL is nice | Learning curve for newbies |
Use the wrapper included by Spring Initializr: ./mvnw or ./gradlew. No global install needed.
4) Create a New Spring Boot Project (Initializr)
Use the website or your IDE wizard.
- Group: com.example
- Artifact: hello-service
- Java: 17 or 21
- Dependencies: Spring Web, DevTools (optional now, glorious later)
CLI (Maven):
curl https://start.spring.io/starter.zip \
-d dependencies=web,devtools \
-d language=java \
-d bootVersion=3.2.5 \
-d javaVersion=21 \
-d groupId=com.example \
-d artifactId=hello-service \
-o hello-service.zip
unzip hello-service.zip && cd hello-service
5) Run the App
Maven:
./mvnw spring-boot:run
Gradle:
./gradlew bootRun
Create a tiny controller to prove life exists:
package com.example.helloservice;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/hello")
public String hello() {
return "Hello, micro-world";
}
}
Test it:
curl -i http://localhost:8080/hello
If you see status 200 and a friendly greeting: you did a thing.
6) Enable Hot Reload (DevTools)
DevTools restarts the app on code change. Add to your build if not present.
Maven pom.xml snippet:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
Now change the controller message and watch your app refresh. Like magic, but legal.
7) Install an HTTP Client
- CLI: curl or HTTPie
- GUI: Postman or Insomnia
- IDE-native: IntelliJ HTTP requests (
.httpfiles)
Pick one and get comfy. You will spam localhost a lot.
8) Install Docker (for Databases and Containers)
- Install Docker Desktop (macOS/Windows) or Docker Engine (Linux)
- Verify:
docker version
Spin up a local Postgres for later microservice antics:
docker run --name pg -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=orders \
-p 5432:5432 -d postgres:16
Optional docker-compose.yml for repeatability:
services:
postgres:
image: postgres:16
environment:
POSTGRES_PASSWORD: secret
POSTGRES_DB: orders
ports:
- "5432:5432"
9) Minimal Spring Boot config for local dev
Use a dev profile for sane defaults.
src/main/resources/application.properties:
server.port=8080
spring.profiles.active=dev
src/main/resources/application-dev.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/orders
spring.datasource.username=postgres
spring.datasource.password=secret
spring.jpa.hibernate.ddl-auto=validate
Profiles let each service adapt to its habitat: dev, test, prod. You will love this when your fleet grows.
Why Does This Matter for Microservices?
- Version alignment: A dozen services on a dozen Java versions equals pain. Pick an LTS and standardize.
- Reproducible builds: Maven/Gradle wrappers ensure everyone builds with the same tool version.
- Environment parity: Docker lets local dev mimic cloud-ish realities without crying over laptop installs.
- Faster feedback loops: DevTools + HTTP clients mean more experiments per hour.
- Isolation: Each service is its own kingdom. Containers help prevent dependency feuds.
Remember the principles from microservices architecture: autonomy, deployability, and loose coupling. Your environment is the scaffolding that makes those principles real.
Examples of Useful Tools and Settings
- Git hooks to run
./mvnw -q -DskipTests packagebefore push - Lombok (enable annotation processing in IDE if you use it)
- Java formatter and checkstyle/spotless for consistent code style
.envfiles for local secrets (do not commit them) and Spring Boot config via env vars
Tiny example of overriding config via env var:
SPRING_DATASOURCE_PASSWORD=supersecret ./mvnw spring-boot:run
Common Mistakes in Setting Up Spring Boot
- Wrong Java version: If you see unsupported class file major version, your JDK is too old for the bytecode.
- JAVA_HOME or PATH misconfigured:
java -versionsays 11 but you thought you installed 21. Your shell remembers. - Port 8080 already in use: Some mystery process is hugging it. Try
server.port=8081or kill the squatter. - Corporate proxy/firewall blocking dependencies: Configure Maven/Gradle proxy settings.
- Docker not running: Containers fail silently when the daemon naps. Open Docker Desktop.
- Apple Silicon images: Use arm64 images where possible; many official images support it now.
- Skipping the wrapper: Global Maven 3.6 on your box, 3.9 in CI. Chaos. Use
./mvnwor./gradlew. - IDE missing annotation processing: Lombok sadness ensues. Turn it on.
Quick Verification Checklist
java -versionshows 17 or 21 (Temurin/Adoptium recommended)- IDE opens and recognizes the project (no red squiggles riot)
./mvnw spring-boot:runor./gradlew bootRunstarts the appcurl http://localhost:8080/helloreturns a greeting- Docker runs
postgres:16and you can connect from the app using the dev profile - DevTools reloads the app when you change code
Summary: Your Spring Boot Development Environment, Tamed
You now have a lean, repeatable Spring Boot development environment: an LTS JDK, a friendly IDE, a build tool wrapper, Docker for support services, and a tiny app that answers when called. This is the runway for everything that comes next in our microservices journey: configuration, data, observability, containers, and scaling your code into a polite distributed system instead of a loud one.
Big idea: consistency compounds. The tighter your local setup, the faster your microservices team ships without stepping on rakes.
Next up, we will containerize this service, wire in a database with migrations, and start acting like the cloud is just someone else’s computer — but with our config under control.
Comments (0)
Please sign in to leave a comment.
No comments yet. Be the first to comment!