Spring BootSpring Boot Initializr
Spring Boot

Spring Boot Initializr

Spring Initializr is the official project generator for Spring Boot applications. It creates a complete, ready-to-run project structure with your chosen dependencies, build tool, Java version, and packaging — in seconds. Available at start.spring.io, through IDE plugins, and via the Spring Boot CLI.

What Is Spring Initializr?

Spring Initializr (start.spring.io) is the official tool for bootstrapping Spring Boot projects. It generates a complete project skeleton — pom.xml or build.gradle, main application class, test class, application.properties, Maven or Gradle wrapper, and .gitignore — all pre-configured and ready to run. Before Initializr, starting a Spring Boot project meant manually creating the directory structure, writing the pom.xml from scratch, declaring all dependencies with correct versions, configuring plugins, and writing the main class. Initializr collapses all of that into a 30-second form submission. Three ways to use Initializr: - Web UI at start.spring.io — fill a form and download a ZIP - IDE integration — IntelliJ IDEA, VS Code, Eclipse all have built-in Initializr support - Spring Boot CLI — spring init command generates projects from the terminal

Using start.spring.io

The web interface at start.spring.io is the most common way to generate a project. Every option you configure translates directly into the generated project's structure and files.
Java
// Options available at start.spring.io:

// Project — build tool:
// Maven  → generates pom.xml + mvnw (Maven wrapper)
// Gradle (Groovy) → generates build.gradle + gradlew
// Gradle (Kotlin) → generates build.gradle.kts + gradlew

// Language:
// Java   → .java source files (most common)
// Kotlin → .kt source files
// Groovy → .groovy source files

// Spring Boot version:
// Always choose the latest RELEASE (not SNAPSHOT or M/RC builds for production)
// 3.2.x → requires Java 17+
// 3.1.x → requires Java 17+
// 2.7.x → requires Java 8+  (old LTS — avoid for new projects)

// Project Metadata:
// Group:        com.example              (reverse domain — your organisation)
// Artifact:     myapp                    (the project/module name)
// Name:         myapp                    (display name — defaults to artifact)
// Description:  My Spring Boot App
// Package name: com.example.myapp        (auto-generated from group + artifact)
// Packaging:    Jar (self-contained) or War (for external server deployment)
// Java version: 21 (LTS — recommended) or 17 (LTS)

// Dependencies — search and add what you need:
// Web:          Spring Web, Spring WebFlux, Spring WebSocket
// Data:         Spring Data JPA, Spring Data MongoDB, Spring Data Redis
// Security:     Spring Security, OAuth2 Resource Server, OAuth2 Client
// Ops:          Spring Boot Actuator, Spring Boot DevTools
// Messaging:    Spring for Apache Kafka, Spring for RabbitMQ
// I/O:          Validation, Java Mail Sender, Spring Batch
// Testing:      (included automatically) JUnit 5, Mockito, AssertJ

Generating via the Spring Boot CLI

The spring init command wraps the Initializr API and generates projects directly from the terminal — no browser needed. Ideal for scripting and automation.
Shell
# List everything Initializr supports:
spring init --list

# Minimal project — Spring Web only:
spring init --dependencies=web myapp

# Full REST API project:
spring init \
  --build=maven \
  --java-version=21 \
  --boot-version=3.2.0 \
  --group-id=com.example \
  --artifact-id=myapp \
  --name="My Application" \
  --package-name=com.example.myapp \
  --packaging=jar \
  --dependencies=web,data-jpa,security,validation,actuator,devtools \
  myapp

# Gradle + Kotlin project:
spring init \
  --build=gradle \
  --language=kotlin \
  --dependencies=web,data-jpa,security \
  myapp-kotlin

# Reactive project with WebFlux:
spring init \
  --dependencies=webflux,data-mongodb-reactive,security,actuator \
  myapp-reactive

# Generate into current directory (no subdirectory created):
spring init --dependencies=web,data-jpa .

# Generate a ZIP file and extract manually:
spring init --dependencies=web,actuator myapp.zip && unzip myapp.zip -d myapp

# Run immediately after generating:
spring init --dependencies=web myapp && cd myapp && ./mvnw spring-boot:run

Generating via the Initializr REST API

start.spring.io exposes a REST API that the CLI, IDEs, and your own scripts can call directly. You can automate project generation in CI pipelines, onboarding scripts, or internal developer tools.
Shell
# Download a project ZIP via curl:
curl https://start.spring.io/starter.zip \
  -d type=maven-project \
  -d language=java \
  -d bootVersion=3.2.0 \
  -d baseDir=myapp \
  -d groupId=com.example \
  -d artifactId=myapp \
  -d name=myapp \
  -d packageName=com.example.myapp \
  -d javaVersion=21 \
  -d dependencies=web,data-jpa,security,actuator,validation,devtools \
  -o myapp.zip

# Extract and enter the project:
unzip myapp.zip && cd myapp

# List supported dependencies via the API:
curl https://start.spring.io/dependencies

# List supported Spring Boot versions:
curl https://start.spring.io/actuator/info

# Generate a pom.xml only (no full project):
curl https://start.spring.io/pom.xml \
  -d dependencies=web,data-jpa \
  -o pom.xml

# Generate a build.gradle only:
curl https://start.spring.io/build.gradle \
  -d type=gradle-project \
  -d dependencies=web,data-jpa \
  -o build.gradle

IntelliJ IDEA Integration

IntelliJ IDEA has built-in Spring Initializr integration — both Community and Ultimate editions. You get the same options as start.spring.io without leaving the IDE.
Java
// Steps to create a Spring Boot project in IntelliJ IDEA:

// 1. File → New → Project
// 2. Select "Spring Boot" from the left panel
//    (IntelliJ IDEA 2023+ — previously called "Spring Initializr")

// 3. Fill in the project settings:
//    Name:         myapp
//    Location:     /path/to/workspace/myapp
//    Language:     Java
//    Type:         Maven (or Gradle - Groovy / Gradle - Kotlin)
//    Group:        com.example
//    Artifact:     myapp
//    Package name: com.example.myapp
//    JDK:          21 (select from installed JDKs)
//    Java:         21
//    Packaging:    Jar

// 4. Click Next → Search and select dependencies:
//    Type "web" → check Spring Web
//    Type "jpa" → check Spring Data JPA
//    Type "security" → check Spring Security
//    Type "mysql" → check MySQL Driver
//    Type "actuator" → check Spring Boot Actuator
//    Type "devtools" → check Spring Boot DevTools
//    Type "validation" → check Validation
//    Type "lombok" → check Lombok

// 5. Click Create → IntelliJ downloads the project and opens it

// 6. IntelliJ automatically:
//    - Imports the Maven/Gradle project
//    - Downloads all declared dependencies
//    - Indexes the project for auto-completion
//    - Detects the Spring Boot application class

// Run the application:
// Click the green play button next to the main() method
// Or right-click MyappApplication.java → Run 'MyappApplication'
// Or use the Run/Debug Configurations toolbar

VS Code Integration

VS Code supports Spring Initializr through the Spring Boot Extension Pack. The experience is command-palette driven.
Java
// Prerequisites — install from VS Code Extensions marketplace:
// "Spring Boot Extension Pack" by VMware (includes all Spring tools)
// Or individually: "Spring Initializr Java Support" by Microsoft

// Generate a new project:
// 1. Open Command Palette: Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS)
// 2. Type: "Spring Initializr: Create a Maven Project"
//    Or:   "Spring Initializr: Create a Gradle Project"
// 3. Follow the prompts:
//    - Spring Boot version: 3.2.0
//    - Project language: Java
//    - Group Id: com.example
//    - Artifact Id: myapp
//    - Packaging type: Jar
//    - Java version: 21
//    - Search and add dependencies (multi-select)
// 4. Choose the destination folder
// 5. VS Code generates and opens the project

// VS Code Spring Boot features after project creation:
// - Spring Boot Dashboard (left panel) — start/stop/restart apps
// - Bean navigation — click to jump to bean definitions
// - @RequestMapping route overview
// - application.properties auto-completion
// - Live application metrics in the editor
// - Endpoint URL hints in controllers

The Generated Project — What You Get

Understanding every file Initializr generates helps you know what to modify, what to leave alone, and what each piece is responsible for.
Java
// Generated structure for a Maven project with web + jpa + security:
//
// myapp/
// ├── .mvn/
// │   └── wrapper/
// │       └── maven-wrapper.properties    ← pins the Maven version used by mvnw
// ├── src/
// │   ├── main/
// │   │   ├── java/
// │   │   │   └── com/example/myapp/
// │   │   │       └── MyappApplication.java   ← @SpringBootApplication entry point
// │   │   └── resources/
// │   │       ├── static/                     ← static web assets (CSS, JS, images)
// │   │       ├── templates/                  ← Thymeleaf/Freemarker templates
// │   │       └── application.properties      ← all app configuration
// │   └── test/
// │       └── java/
// │           └── com/example/myapp/
// │               └── MyappApplicationTests.java  ← context load test
// ├── .gitignore                              ← pre-configured for Java/Maven
// ├── HELP.md                                 ← links to Spring Boot docs
// ├── mvnw                                    ← Maven wrapper script (Unix)
// ├── mvnw.cmd                                ← Maven wrapper script (Windows)
// └── pom.xml                                 ← all dependencies and build config

// MyappApplication.java — the generated main class:
package com.example.myapp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MyappApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyappApplication.class, args);
    }
}

// MyappApplicationTests.java — the generated test class:
package com.example.myapp;

import org.springframework.boot.test.context.SpringBootTest;
import org.junit.jupiter.api.Test;

@SpringBootTest
class MyappApplicationTests {

    @Test
    void contextLoads() {
        // Verifies the entire Spring ApplicationContext starts without errors
        // Run this after every major dependency or configuration change
    }
}

The Generated pom.xml — Explained

The generated pom.xml is already fully functional. Understanding every section helps you know what to add, modify, or remove as your project grows.
XML
<!-- Generated pom.xml for a web + data-jpa + security project: -->
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>

    <!-- Inherits Spring Boot's dependency management and plugin config: -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.0</version>
        <relativePath/>
    </parent>

    <!-- Project coordinates — uniquely identifies your project: -->
    <groupId>com.example</groupId>
    <artifactId>myapp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>myapp</name>
    <description>My Spring Boot Application</description>

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

    <dependencies>
        <!-- Your chosen starters — no version needed (parent manages): -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <!-- DevTools — excluded from production JAR automatically: -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>

        <!-- Database driver — add manually after generation: -->
        <!-- (Initializr adds the driver you selected) -->
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- Testing — JUnit 5 + Mockito + AssertJ + MockMVC: -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Creates the executable fat JAR on mvn package: -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

Running the Generated Project

The generated project is immediately runnable — no configuration required beyond setting datasource properties if you added JPA.
Shell
# The Maven wrapper (mvnw) is included — no Maven installation needed:

# Run the application:
./mvnw spring-boot:run         # Unix/macOS
mvnw.cmd spring-boot:run       # Windows

# Run tests:
./mvnw test

# Build the executable JAR:
./mvnw clean package

# Run the JAR:
java -jar target/myapp-0.0.1-SNAPSHOT.jar

# Skip tests during build (faster):
./mvnw clean package -DskipTests

# Run with a specific profile:
./mvnw spring-boot:run -Dspring-boot.run.profiles=dev

# The contextLoads test in MyappApplicationTests runs with mvn test
# If it fails, the Spring context has a configuration error —
# fix it before writing any other code

# First thing to add to application.properties for a JPA project:
# spring.datasource.url=jdbc:mysql://localhost:3306/mydb
# spring.datasource.username=root
# spring.datasource.password=secret
# spring.jpa.hibernate.ddl-auto=update