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.
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; @RestController public class FirstController { @RequestMapping("/hello") 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