Getting Started with Spring Boot 3

Spring

Spring Boot 3.0 is a major release that brings a lot of new features and improvements. In this article, we’ll explore how to get started with Spring Boot 3 and what’s new in this version.

Prerequisites

Before we begin, make sure you have the following installed:

Key Features in Spring Boot 3

Create the Application

Create a Spring Boot project with the spring-boot-starter-web dependency, then add a small REST controller. Spring Boot discovers the controller automatically when it is below the application class package.

package com.sivalabs.demo;

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

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}
package com.sivalabs.demo;

import java.util.Map;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
class GreetingController {

    @GetMapping("/api/greeting")
    Map<String, String> greeting() {
        return Map.of("message", "Hello from Spring Boot 3");
    }
}

Start the application with Maven:

./mvnw spring-boot:run

Then open http://localhost:8080/api/greeting to receive the JSON response.

Configure the Application

Spring Boot configuration can live in src/main/resources/application.yml:

spring:
  application:
    name: demo-service

server:
  port: 8080

Conclusion

Spring Boot 3 brings significant improvements and modernization to the Spring ecosystem.