Setup: JDK & Project

Install the JDK

Spring Boot 4 needs Java 17 or newer and supports Java 25. Take the newest LTS:

# macOS
brew install --cask temurin@25

# Linux
sudo apt install openjdk-25-jdk

# Windows
winget install EclipseAdoptium.Temurin.25.JDK

# any platform, several versions side by side
sdk install java 25-tem      # sdkman.io
java --version     # openjdk 25 …

No Maven or Gradle install needed — generated projects ship a wrapper.

Generate a project

Use start.spring.io in the browser, or the API:

curl https://start.spring.io/starter.zip \
  -d bootVersion=4.0.0 -d javaVersion=25 -d type=maven-project \
  -d groupId=com.example -d artifactId=demo -d name=demo \
  -d dependencies=web,data-jpa,h2,actuator,validation \
  -o demo.zip && unzip demo.zip -d demo

What you get:

demo/
  pom.xml
  mvnw  mvnw.cmd                     Maven wrapper — no local Maven needed
  src/main/java/com/example/demo/DemoApplication.java
  src/main/resources/application.properties
  src/test/java/com/example/demo/DemoApplicationTests.java

The build file

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>4.0.0</version>
</parent>

<properties>
    <java.version>25</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

A starter is a dependency that pulls in a whole topic. The parent pins every version, so your dependencies carry no <version> tag.

New in Spring Boot 4

The code base is fully modularized: auto-configuration now lives in many small, focused jars instead of one big spring-boot-autoconfigure. Starters keep working unchanged — you just ship fewer classes you never use.

Run it

cd demo
./mvnw spring-boot:run       # http://localhost:8080
./mvnw test
./mvnw package               # target/demo-0.0.1-SNAPSHOT.jar
java -jar target/demo-0.0.1-SNAPSHOT.jar

Editor

  • IntelliJ IDEA Community — open pom.xml, set the project SDK to 25
  • VS Code — install Extension Pack for Java and Spring Boot Extension Pack
Port already in use?

Another process holds 8080. Start with ./mvnw spring-boot:run -Dspring-boot.run.arguments=--server.port=8081.

★ Exercises

  1. Install a JDK and print java --version.
  2. Generate a project with the web and actuator dependencies.
  3. Start it and open http://localhost:8080/actuator/health.
  4. Run ./mvnw dependency:tree and find out what spring-boot-starter-web pulled in.