Spring Lab 1 Hello Message |Video upload date:  · Duration: PT10M45S  · Language: EN

Compact Spring Boot lab showing how to build a Hello message endpoint run the app and test locally with simple tips

Why this tiny lab matters

This quick Spring Boot tutorial shows how to expose a Hello endpoint using a REST controller so you can validate wiring, configuration and the fact that your computer still runs Java. You will use Spring Boot, Spring Web, Java and either Maven or Gradle to create a minimal web app that responds to HTTP requests.

Prerequisites

  • JDK 11 or later
  • Maven or Gradle installed
  • An IDE or Spring Initializr

Step 1 Initialize the project

Visit start.spring.io or use your IDE starter and include the Web dependency. Choose Maven or Gradle, pick group and artifact names and move on. This is a lab not a naming contest.

Step 2 Create the REST controller

Add a tiny controller that handles GET requests at /hello and returns a friendly greeting. Keep it small and obvious so debugging does not become a personality test.

package com.example.demo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @Value("${greeting.message:Hello World}")
    private String greeting;

    @GetMapping("/hello")
    public String hello() {
        return greeting;
    }
}

Step 3 Run the application

Start the app from your IDE by running the main class that calls SpringApplication.run. From the command line use the build tool command that feels right for you.

  • Maven: mvn spring-boot:run
  • Gradle: ./gradlew bootRun

Spring Boot listens on localhost port 8080 by default unless you change server.port in application.properties or via environment settings.

Step 4 Test the endpoint

Open a browser at http://localhost:8080/hello or use curl and pretend you are a command line wizard.

curl http://localhost:8080/hello
# Expected output
Hello World

Step 5 Make the greeting configurable

Move the greeting into src/main/resources/application.properties so you can change messages without editing code. The controller above injects the value with @Value and has a fallback of Hello World so missing properties will not ruin your day.

# src/main/resources/application.properties
greeting.message=Hello from Spring Boot

If you want different text for different environments use profile specific properties like application-dev.properties and set spring.profiles.active. That is how professionals pretend to be organized.

Tips and next steps

  • Switch the handler to return JSON if you need structured responses for clients
  • Secure the endpoint before you share your laptop with strangers
  • Try adding logging and health checks to move beyond the smallest viable microservice

There you go. A minimal Spring Boot web app, a REST controller, and a configurable hello message. Use Maven or Gradle as you prefer. Now go impress someone with the most basic but essential API you can build.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.