Project Starters

Spring Boot Microservice Starter (Java)

Scaffold a Spring Boot service from Spring Initializr, add a REST endpoint, and run it — the whole ritual in one page.

JavaSpring BootmicroservicesREST API

Before you start

Check Java — Spring Boot 3.x needs Java 17 or newer:

java --version

You do not need Maven or Gradle installed; the generated project ships its own wrapper (mvnw / gradlew).

Scaffold at Spring Initializr

Go to start.spring.io and choose:

  • Project: Maven (or Gradle if that's your team's habit)
  • Language: Java, Boot version: latest stable
  • Dependencies — the microservice trio:
    • Spring Web (REST endpoints)
    • Spring Boot Actuator (health/metrics endpoints)
    • Spring Boot DevTools (auto-restart on change)

Click Generate, unzip, open in your IDE.

Prefer the terminal? Same thing via curl:

curl https://start.spring.io/starter.zip -d dependencies=web,actuator,devtools -d javaVersion=21 -d artifactId=my-service -o my-service.zip

Run it

./mvnw spring-boot:run        # Windows: mvnw.cmd spring-boot:run

It starts on port 8080. Prove it's alive:

curl http://localhost:8080/actuator/health

First endpoint

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

package com.example.myservice;

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

@RestController
public class HelloController {

    @GetMapping("/hello")
    public String hello() {
        return "Service is up";
    }
}

Save (DevTools restarts automatically) and hit http://localhost:8080/hello.

Config you always end up needing

src/main/resources/application.properties:

server.port=8081
spring.application.name=my-service
management.endpoints.web.exposure.include=health,info,metrics

Common gotchas

  • "Web server failed to start. Port 8080 was already in use": another service is running — change server.port or kill the other process.
  • Controller not found (404): your class is outside the main package. Spring only scans the package containing @SpringBootApplication and below — keep controllers in subpackages of it.
  • UnsupportedClassVersionError: your terminal's java is older than the project's target — point JAVA_HOME at 17+.
  • Building more than one service: repeat this recipe per service, each in its own folder/repo with its own port; wire them together later (API gateway, service discovery) only when you actually need it.