Saturday, July 25, 2026

How to Create a Spring Boot Project Using Spring Initializr (Step-by-Step Guide)

How to Create a Spring Boot Project Using Spring Initializr (Step-by-Step Guide)

Spring Boot simplifies Java application development by providing opinionated defaults, embedded servers, and automatic configuration. Instead of spending time configuring XML files and dependencies manually, you can create a production-ready application in just a few minutes.

In this tutorial, you'll learn how to:

  • Create a Spring Boot project using Spring Initializr
  • Understand each project configuration option
  • Import the project into IntelliJ IDEA, Eclipse, or Spring Tool Suite (STS)
  • Run your first Spring Boot application
  • Verify that the application is working correctly

Prerequisites

  • Java 17 or Java 21 installed
  • Maven (optional, as Spring Boot includes Maven Wrapper)
  • IntelliJ IDEA, Eclipse, or Spring Tool Suite (STS)
  • Internet connection

What is Spring Boot?

Spring Boot is an extension of the Spring Framework that simplifies Java application development.

It provides:

  • Embedded Tomcat Server
  • Auto Configuration
  • Starter Dependencies
  • Production Ready Features
  • Minimal Configuration

What is Spring Initializr?

Spring Initializr is an online project generator that creates a ready-to-use Spring Boot project with the dependencies you select.

It automatically generates:

  • Maven or Gradle project
  • Project structure
  • Starter dependencies
  • Main application class

Step 1: Open Spring Initializr

Visit the Spring Initializr website and configure the project as shown below.

Option Value
Project Maven
Language Java
Spring Boot Latest Stable Version
Group com.code2learn
Artifact springboot-demo
Packaging Jar
Java 17 or 21

Step 2: Add Dependencies

Select the required dependencies.

  • Spring Web
  • Spring Data JPA (Optional)
  • Spring Security (Optional)
  • Lombok (Optional)
  • Validation (Optional)
  • MySQL Driver (Optional)

Step 3: Generate the Project

Click Generate to download the project ZIP file. Extract the ZIP file to your local machine.

Step 4: Import Project into IntelliJ IDEA

  1. Open IntelliJ IDEA.
  2. Click Open.
  3. Select the extracted project folder.
  4. Wait until Maven downloads all dependencies.

Project Structure


src
 ├── main
 │   ├── java
 │   ├── resources
 └── test

pom.xml

src/main/java contains Java source files.

src/main/resources contains:

  • application.properties
  • Static resources
  • Templates

pom.xml contains all Maven dependencies.

Create a Simple REST Controller


@RestController
public class HelloController {

    @GetMapping("/")
    public String hello() {
        return "Welcome to Code2Learn!";
    }

}

Run the Application

Run the Spring Boot main class.

If everything is configured correctly, you will see:


Tomcat started on port(s): 8080
Started Application in 2.4 seconds

Test the Application

Open your browser and visit:


http://localhost:8080/

You should see:


Welcome to Code2Learn!

Common Errors

Port 8080 Already in Use

Stop the application using port 8080 or change the port in application.properties.

Java Version Mismatch

Ensure the installed JDK version matches the selected Java version.

Maven Dependencies Not Downloading

Reload the Maven project or verify your internet connection.

IDE Cannot Find Spring Classes

Refresh Maven dependencies and rebuild the project.

Frequently Asked Questions

Is Spring Boot free?

Yes. Spring Boot is open source and free to use.

Which Java version should I use?

Java 17 or Java 21 is recommended for new applications.

Maven or Gradle?

Maven is easier for beginners, while Gradle offers more flexibility for larger projects.

Do I need Tomcat separately?

No. Spring Boot includes an embedded Tomcat server.

Conclusion

Spring Boot makes Java development significantly easier by reducing boilerplate configuration and allowing developers to focus on business logic.

Using Spring Initializr, you can generate a fully configured project within minutes and immediately start building REST APIs, web applications, and enterprise applications.

In the next tutorial, we'll build our first REST API using Spring Boot.

Related Tutorials

  • Spring Boot REST API Tutorial
  • Spring Boot Dependency Injection
  • Spring Data JPA CRUD Example
  • Spring Boot Validation Example
  • Spring Security with JWT
  • Spring Boot Interview Questions

How to Create a Spring Boot Project Using Spring Initializr (Step-by-Step Guide)

How to Create a Spring Boot Project Using Spring Initializr (Step-by-Step Guide) Spring Boot simplifies Java application development by pr...