Initial Setup

Get Spring Boot installed and create your first web application. This guide walks you through installation and building your first Spring Boot app.

🎯 What You’ll Accomplish

By the end of this tutorial, you’ll have:

  • βœ… Java and Spring Boot set up
  • βœ… Your first Spring Boot project created
  • βœ… REST API endpoint running

πŸ“‹ Prerequisites

  • Java 17 or later
  • Maven or Gradle
  • IDE (IntelliJ IDEA, Eclipse, or VS Code)

πŸ’Ύ Step 1: Create Spring Boot Project

Visit start.spring.io and create a project with:

  • Spring Boot 3.2.x
  • Dependencies: Spring Web

Or use command line:

curl https://start.spring.io/starter.zip \
  -d dependencies=web \
  -d bootVersion=3.2.0 \
  -d javaVersion=17 \
  -o spring-boot-demo.zip
unzip spring-boot-demo.zip
cd spring-boot-demo

πŸš€ Step 2: Create Your First Controller

Create src/main/java/com/example/demo/HelloController.java:

package com.example.demo;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @GetMapping("/")
    public String hello() {
        return "Hello, Spring Boot!";
    }

    @GetMapping("/api/greeting")
    public Greeting greeting() {
        return new Greeting("Hello, World!");
    }
}

record Greeting(String message) {}

πŸ“Š Step 3: Run the Application

./mvnw spring-boot:run

# Or with Gradle
./gradlew bootRun

Visit:

  • http://localhost:8080/ - See hello message
  • http://localhost:8080/api/greeting - See JSON response

βœ… Verification Checklist

Before moving forward, verify:

  • Project created successfully
  • Application starts without errors
  • Endpoints respond correctly

πŸŽ‰ You’re Done!

You’ve successfully created your first Spring Boot web application.

πŸ“š What’s Next?

Quick learner: Java Spring Boot Quick Start

Code-first learner: Java Spring Boot By Example

Last updated