Skip to main content

Command Palette

Search for a command to run...

Spring Boot - Create a Simple RESTful Web Service

Published
1 min read
M

Mohamad's interest is in Programming (Mobile, Web, Database and Machine Learning). He is studying at the Center For Artificial Intelligence Technology (CAIT), Universiti Kebangsaan Malaysia (UKM).

Objective: Implement a basic REST controller that returns a greeting message.

Steps:

  1. Create a REST Controller:

    • Add a new class annotated with @RestController.
    package com.example.demo;

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

    @RestController
    public class GreetingController {
        @GetMapping("/greeting")
        public String greeting() {
            return "Hello, World!";
        }
    }
  1. Test the Endpoint:

I
Issy1y ago

Love your insights on RESTful API efficiency! After diving into EchoAPI, I realized how much easier it is to simulate API requests and get accurate responses for my tests, all without a live server.