79806735

Date: 2025-11-01 18:03:58
Score: 1
Natty:
Report link

When I first started working with Java, building a web application felt heavy. A lot of configuration, XML everywhere, and you had to manually set up servers. That all changed when I discovered Spring Boot.

If you're new to Spring or you want a clean starting point for backend development, this walks you through what Spring Boot is and how to build a simple REST API.


What is Spring Boot ?

Spring Boot is a framework that makes it easy to create Java applications with almost no configuration.

It handles the heavy lifting for you:

You just write your code, run the application, and Spring Boot takes care of the rest.


Why use Spring Boot ?

Here are the things that made me personally appreciate Spring Boot:

  1. it has an embedded server.

  2. auto configuration .

  3. very fast to get started .


Step 1: Create a Spring Boot Project

Go to : spring.io

Choose:

Download the project and open it in your IDE .

Spring Boot generates everything you need to start immediately.


Step 2: Create Your First REST API

Inside your project, create a new class:

HelloController.java

package com.example.demo.controllers;

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

@RestController
public class HelloController {

    @GetMapping("/hello")
    public String hello() {
        return "Hello World!";
    }
}

That’s it.

How it works:


Step 3: Run the Application

You can run the project in two ways:

1 - Using your IDE

Simply run the main() method inside DemoApplication.java.

2 - Using Maven

Open your terminal and run:

mvn spring-boot:run

The app starts on port 8080 by default.

Now open:

http://localhost:8080/hello

You should see:

Hello World!

Step 4: Update Application Properties

Spring Boot uses application.properties or application.yml to configure your app.

For example, to change the port:

server.port=2025

Or using YAML:

server:
  port: 2025

Restart the app, and it will now run on:

http://localhost:2025


What’s next?

If you're starting your Spring journey, here are the next topics you should take a look at:

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • Starts with a question (0.5): When I
  • Low reputation (1):
Posted by: Ayoub