Spring Boot Setup and Installation

In simple terms: Getting set up is a one-time cost — install a JDK, pick a build tool, generate a project with Spring Initializr, and confirm it runs before writing any application code.

Prerequisites

  • Install a supported JDK, preferably an LTS release such as Java 17 or 21.
  • Install an IDE such as IntelliJ IDEA, Eclipse, or VS Code.
  • Choose Maven or Gradle as the build tool.
  • Have a terminal and Git available for running the wrapper scripts and cloning samples.

Installing the JDK

Spring Boot needs a Java Development Kit, not just a runtime. Any recent LTS distribution (Temurin, Amazon Corretto, Microsoft Build of OpenJDK, Oracle) works the same way from Spring Boot's point of view — pick one and install it consistently across your team.

Platform Common install method Notes
Windows MSI installer or a version manager (e.g. winget install EclipseAdoptium.Temurin.21.JDK) Ensure JAVA_HOME and %JAVA_HOME%\bin are on PATH.
macOS brew install temurin@21 or an installer package Homebrew manages JAVA_HOME for you when you shell out via /usr/libexec/java_home.
Linux Distro package manager (apt, dnf) or SDKMAN! SDKMAN! (sdk install java 21-tem) makes switching versions easy.

After installing, verify the JDK is on your PATH and is the version you expect:

java -version
javac -version
Tip: If java -version prints an older release than you just installed, another JDK is earlier on your PATH or JAVA_HOME still points at it. Fix the environment variable rather than uninstalling anything.

Maven vs Gradle

Both build tools compile your code, run tests, resolve dependencies, and package a runnable JAR. Spring Initializr supports either, and Boot works identically on top of them — the choice is mostly about syntax preference and existing team conventions.

Maven Gradle
Syntax style Declarative XML (pom.xml) Groovy or Kotlin DSL (build.gradle / build.gradle.kts)
Wrapper file mvnw / mvnw.cmd gradlew / gradlew.bat
Build command ./mvnw clean package ./gradlew build
Run command ./mvnw spring-boot:run ./gradlew bootRun
Typical use Teams that want explicit, convention-heavy configuration Teams that want faster incremental builds and a scriptable DSL
Tip: Whichever you choose, commit the wrapper files (mvnw, gradlew, and their supporting .mvn/gradle/wrapper folders) so every teammate and CI runner builds with the exact same tool version.

Create a project with Spring Initializr

Open start.spring.io and fill in a few fields before generating the project ZIP. Each choice affects the generated files:

Field What it affects
Project Maven or Gradle — determines whether you get pom.xml or build.gradle(.kts) plus the matching wrapper.
Language Java, Kotlin, or Groovy source files and the compiler plugin used.
Spring Boot version The parent/BOM version, which pins compatible library versions for every starter you add.
Group / Artifact Your base package name and the generated JAR's artifact id and default class name.
Packaging Jar (embedded server, run directly) vs War (deploy to an external servlet container).
Java version The source/target bytecode level and language features available to you.
Dependencies Which starters are added to the build file — this drives which auto-configuration classes can activate later.
Project setup flow
ChooseJDK and build tool
GenerateSelect dependencies
OpenImport the project
RunStart the main class

IDE setup

  • IntelliJ IDEA: File → Open, select the extracted project folder, and let it auto-import the Maven/Gradle model.
  • VS Code: install the "Extension Pack for Java" and "Spring Boot Extension Pack", then File → Open Folder on the project.
  • Eclipse: use File → Import → Existing Maven/Gradle Project and point it at the folder containing pom.xml or build.gradle.

Run from the terminal

./mvnw spring-boot:run

# Or build and run a JAR
./mvnw clean package
java -jar target/demo-0.0.1-SNAPSHOT.jar
Tip: Use the project wrapper (mvnw or gradlew) so everyone uses the project's expected build-tool version.

Verify your setup

A successful start prints an ASCII banner, the active profile, and a line confirming the embedded server is listening. Look for output similar to this:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.3.0)

Starting DemoApplication using Java 21
Tomcat initialized with port(s): 8080 (http)
Tomcat started on port(s): 8080 (http)
Started DemoApplication in 1.284 seconds (process running for 1.6)

If you see Tomcat started on port(s): 8080 (or another port you configured), the embedded server is up and the application context finished loading successfully.

Verify JDK Setup More Thoroughly

After installation, verify everything is working correctly:

java -version
javac -version
echo $JAVA_HOME  # On Windows: echo %JAVA_HOME%

All three commands should show the same Java version (e.g., 21.0.1). If they show different versions or can't be found, your PATH or JAVA_HOME needs adjustment.

Creating Your First Project - Step by Step

Step 1: Visit Spring Initializr

  1. Go to https://start.spring.io
  2. You'll see a form with several fields
  3. This tool generates a new Spring Boot project with your choices

Step 2: Fill in the Form

For a beginner learning REST APIs:

  • Project: Select "Maven" (if unsure)
  • Language: Select "Java"
  • Spring Boot version: Select latest stable (e.g., 3.3.0)
  • Group: com.example (or your company domain)
  • Artifact: tutorial-app (or your project name)
  • Name: Tutorial App
  • Description: My first Spring Boot app
  • Package name: com.example.tutorialapp
  • Packaging: Jar
  • Java version: 21

Step 3: Add Dependencies

Click "Add Dependencies" and search for these (click to add each):

Dependency Why you need it
Spring Web Enables REST API and web server
Spring Data JPA Database access and ORM
H2 Database In-memory database for testing
Lombok Reduces boilerplate (getters/setters/toString)
Spring Boot DevTools Auto-restart during development
Spring Boot Starter Test Testing framework (automatically included)

Step 4: Generate and Download

  1. Click the green "GENERATE" button
  2. A ZIP file downloads
  3. Extract it to a convenient location (e.g., ~/projects/tutorial-app)

Project Structure Explained

tutorial-app/
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   └── com/example/tutorialapp/
│   │   │       └── TutorialAppApplication.java  ← Main class, run this!
│   │   └── resources/
│   │       └── application.properties            ← Configuration here
│   └── test/
│       └── java/                                 ← Write tests here
├── target/                                       ← Build output (ignore)
├── pom.xml                                       ← Dependencies defined here
└── mvnw                                          ← Run Maven (wrapper)

Running Your First Project

Option 1: From IDE (Recommended for beginners)

  1. Open the project in IntelliJ IDEA or VS Code
  2. Find the TutorialAppApplication.java file in src/main/java
  3. Right-click on it and select "Run" or press Ctrl+Shift+F10
  4. Watch the console for the "Started" message
  5. Visit http://localhost:8080 in your browser (you should see an error page - that's normal!)

Option 2: From Command Line

# Navigate to project directory
cd tutorial-app

# Run using Maven
./mvnw spring-boot:run

# Or build first, then run the JAR
./mvnw clean package
java -jar target/tutorial-app-0.0.1-SNAPSHOT.jar

What It Means When Your App is Running

✅ Success signs (look for these in console):

  • Spring Boot :: (v3.3.0) - Spring Boot version
  • Tomcat initialized with port(s): 8080 (http) - Server starting
  • Tomcat started on port(s): 8080 (http) - Server ready ✓
  • Started TutorialAppApplication in 2.345 seconds - App fully loaded

Next Steps After Setup

  1. Write your first controller: Create a REST endpoint that returns "Hello, World!"
  2. Add a database entity: Create a User or Product class mapped to a table
  3. Create a repository: Define a JpaRepository for database access
  4. Build a complete CRUD API: Create, Read, Update, Delete operations
  5. Add validation: Ensure incoming data is correct before saving
  6. Add error handling: Return meaningful error messages to clients

Development Tips

Tip Benefit
Use Spring Boot DevTools (included in dependencies) Auto-restart your app when you save code changes
Use IDE Run button instead of terminal Faster, better console output, easier debugging
Read application startup logs carefully Error messages tell you what's misconfigured
Use H2 Database Console for testing Visit http://localhost:8080/h2-console to see test data
Keep application.properties minimal Use Spring Boot defaults, override only what's necessary

Troubleshooting

Problem Cause Solution
javac: 'release' version 21 not supported JDK version mismatch Run java -version. Install JDK 21 or higher, or change project's Java version in pom.xml
Address already in use Port 8080 taken Add to application.properties: server.port=8081
Permission denied: ./mvnw Script not executable (macOS/Linux) Run: chmod +x mvnw
BUILD SUCCESS but app doesn't start Missing main class Ensure @SpringBootApplication is on your main class
Cannot find symbol: class SpringBootApplication Dependencies not downloaded Run ./mvnw clean install and restart IDE
IDE shows red squigglies everywhere IDE not recognizing project structure Reload project: Right-click project → Maven → Reload Project
Error: Could not find or load main class Project not compiled Run ./mvnw clean compile first

IDE-Specific Tips

IntelliJ IDEA

  • Right-click pom.xml → "Add as Maven Project"
  • Use Run → Edit Configurations to customize how the app starts
  • View → Tool Windows → Terminal to open built-in terminal

VS Code

  • Install "Extension Pack for Java"
  • Install "Spring Boot Extension Pack"
  • Use command palette: Ctrl+Shift+P → "Java: Debug"

Eclipse

  • File → Import → Maven → Existing Maven Projects
  • Right-click project → Run As → Maven Build... (Goal: spring-boot:run)
Next: Project Structure →

Continue learning