Add REST Controller to Spring Boot Application

Last Updated: November 18, 2020

In this post, we will see how to add REST controller to Spring Boot Application.
First you can create the Spring Boot Applicatin using Netbean IDE.

You can create the Java class FirstController in your Source Packages folder of the Netbeans IDE.
Boot Start

You can add the following code to Class you created

Add the @RestController to your class

package com.codekayak.bootstart;

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

public class FirstController {
    public String sayHello(){
        return "Hello";

Now you can build and run the application.
Open the URL http://localhost:8080/hello and you will see “hello” in your browser