Spring Boot Tutorial 0/110 lessons ~6 min read Lesson 7

    First Application

    Let's build, run and hit your first Spring Boot endpoint.

    Course progress0%
    Focus
    3 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    Let's build, run and hit your first Spring Boot endpoint. This is the smallest production-shaped app: REST, JSON, validation, dependency injection.

    Syntax reference

    Run it:

    bash
    # Maven
    ./mvnw spring-boot:run
    # or
    ./mvnw -q -DskipTests package
    java -jar target/orders-0.0.1-SNAPSHOT.jar
    # Hit it
    curl http://localhost:8080/api/orders/42
    # → {"id":42,"status":"Pending","amountCents":4999}

    Informative example

    OrdersApplication.java — entry point + a controller:

    ts
    package com.acme.orders;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.web.bind.annotation.*;
    @SpringBootApplication
    public class OrdersApplication {
    public static void main(String[] args) {
    SpringApplication.run(OrdersApplication.class, args);
    }
    }
    @RestController
    @RequestMapping("/api/orders")
    class OrderController {
    @GetMapping("/{id}")
    public OrderResponse getOne(@PathVariable Long id) {
    return new OrderResponse(id, "Pending", 4999);
    }
    }
    record OrderResponse(Long id, String status, int amountCents) {}
    Ready to mark this lesson complete?Track your journey across the entire course.