โ† Back to blog
Java Published on 2024-12-20 ยท 5 min read

Getting Started with Spring Boot 3

Learn how to create your first Spring Boot application with Java 21

Getting Started with Spring Boot 3

Spring Boot makes it easy to create stand-alone, production-grade Spring applications. In this guide, we'll create our first application using Java 21 and Spring Boot 3.

Prerequisites

Before we begin, make sure you have:

  • Java 21 or later installed
  • Maven or Gradle
  • Your favorite IDE (IntelliJ IDEA recommended)

Creating Your First Application

The easiest way to start is using Spring Initializr. You can also create the project manually:

java
@SpringBootApplication
public class MyApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}

Creating a REST Controller

Let's create a simple REST endpoint:

java
@RestController
@RequestMapping("/api")
public class HelloController {

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

    @GetMapping("/hello/{name}")
    public String helloName(@PathVariable String name) {
        return "Hello, " + name + "!";
    }
}

Running the Application

Run your application using:

bash
./mvnw spring-boot:run

Then visit http://localhost:8080/api/hello in your browser.

Next Steps

  • Learn about dependency injection
  • Explore Spring Data JPA for database access
  • Add security with Spring Security
spring-bootjavabackend

Made with Angular & PrimeNG

ยฉ 2025 Java Angular Blog