TExcelTAD
Home › Spring Boot › Spring Boot Get Started

Spring Boot Get Started

To build a Spring Boot application you need a JDK (17 or newer; this course uses 21) and a build tool — Maven or Gradle. You do not need to install either build tool globally: every generated project ships with a wrapper script (mvnw or gradlew) that downloads the right version on first use.

Check your Java installation

bash · try it yourself
java -version
openjdk version "21.0.8" 2025-07-15 LTS
OpenJDK Runtime Environment Temurin-21.0.8+9 (build 21.0.8+9-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.8+9 (build 21.0.8+9-LTS, mixed mode, sharing)

Any distribution works (Eclipse Temurin, Amazon Corretto, Oracle, Microsoft…). If the major version is below 17, Spring Boot 3 will refuse to start.

Generate a project with Spring Initializr

start.spring.io — the Spring Initializr — generates a ready-to-run project. Choose:

Field Value used in this course
Project Maven (or Gradle - Kotlin)
Language Java
Spring Boot 3.5.x (the latest non-SNAPSHOT)
Group / Artifact com.example / tasks
Packaging Jar
Java 21
Dependencies Spring Web, Validation, Spring Data JPA, H2 Database

Click Generate, unzip the archive and open the folder in your IDE (IntelliJ IDEA, VS Code with the Java extensions, or Eclipse). The same thing works from the terminal, because the Initializr is also an HTTP API:

bash · try it yourself
curl -s https://start.spring.io/starter.zip \
  -d type=maven-project -d bootVersion=3.5.6 -d javaVersion=21 \
  -d groupId=com.example -d artifactId=tasks -d name=tasks \
  -d dependencies=web,validation,data-jpa,h2 -o tasks.zip
unzip -q tasks.zip -d tasks && ls tasks
HELP.md  mvnw  mvnw.cmd  pom.xml  src

The key part of pom.xml

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

<properties>
    <java.version>21</java.version>
</properties>

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

Notice that the dependencies have no version numbers. The spring-boot-starter-parent imports a bill of materials that pins compatible versions of hundreds of libraries (Jackson, Hibernate, Tomcat, JUnit…), so you never have to work out which versions go together.

The Gradle equivalent (build.gradle.kts):

kotlin
plugins {
    java
    id("org.springframework.boot") version "3.5.6"
    id("io.spring.dependency-management") version "1.1.7"
}

java { toolchain { languageVersion = JavaLanguageVersion.of(21) } }

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-web")
    testImplementation("org.springframework.boot:spring-boot-starter-test")
}

Run the application

bash · try it yourself
cd tasks
./mvnw spring-boot:run
[INFO] Scanning for projects...
[INFO] --------------------------< com.example:tasks >--------------------------
[INFO] Building tasks 0.0.1-SNAPSHOT
[INFO] >>> spring-boot:3.5.6:run (default-cli) > test-compile @ tasks >>>
[INFO] --- compiler:3.14.0:compile (default-compile) @ tasks ---
[INFO] Compiling 1 source file with javac [debug parameters release 21] to target/classes

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.5.6)

2025-10-16T09:12:03.412+07:00  INFO 48211 --- [tasks] [           main] com.example.tasks.TasksApplication       : Starting TasksApplication using Java 21.0.8 with PID 48211
2025-10-16T09:12:03.415+07:00  INFO 48211 --- [tasks] [           main] com.example.tasks.TasksApplication       : No active profile set, falling back to 1 default profile: "default"
2025-10-16T09:12:04.301+07:00  INFO 48211 --- [tasks] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2025-10-16T09:12:04.874+07:00  INFO 48211 --- [tasks] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path '/'
2025-10-16T09:12:04.889+07:00  INFO 48211 --- [tasks] [           main] com.example.tasks.TasksApplication       : Started TasksApplication in 1.873 seconds (process running for 2.204)

The server keeps running until you press Ctrl+C. With Gradle the command is ./gradlew bootRun. In an IDE you can simply run the main method of TasksApplication.

There are no endpoints yet, so any URL returns Spring Boot's default JSON error:

bash · try it yourself
curl -s localhost:8080/
{"timestamp":"2025-10-16T02:12:31.540+00:00","status":404,"error":"Not Found","path":"/"}

A 404 response proves the server is up — you will add your first endpoint in the controller lesson.

Useful build commands

Maven Gradle Does
./mvnw spring-boot:run ./gradlew bootRun compile and start the app
./mvnw test ./gradlew test run the tests
./mvnw package ./gradlew bootJar build an executable JAR
./mvnw dependency:tree ./gradlew dependencies show resolved libraries

Tip: Add spring-boot-devtools (scope runtime, optional) while developing. It restarts the application automatically whenever a class on the classpath changes, which is much faster than a full restart.

Test yourself

Why do Spring Boot starter dependencies in pom.xml usually have no <version>?

  1. Maven always picks the newest version
  2. The Spring Boot parent's bill of materials manages the versions
  3. Versions are optional in Maven
  4. They are downloaded from start.spring.io

Which command starts a Maven-based Spring Boot app from the terminal?

  1. mvn start
  2. ./mvnw spring-boot:run
  3. java spring run
  4. ./mvnw bootRun

What is the minimum Java version for Spring Boot 3.x?

  1. 8
  2. 11
  3. 17
  4. 21