This content originally appeared on DEV Community and was authored by Atharva Siddhabhatti
Installation
Clone the repository from here Click Here
Import Maven based project in any of your Favourite IDE.
./mvnw spring-boot:run
Output
Open in Browser
http://localhost:5000/hello-world
http://localhost:5000/helloworld-bean
Usage
HelloWorldController.java
helloWorld() method returning a string "Hello World".
@GetMapping("/hello-world")
public String helloWorld() {
return "Hello World";
}
helloWorldBean() method returning a bean.
@GetMapping("/helloworld-bean")
public HelloWorldBean helloWorldBean() {
return new HelloWorldBean("Hello World");
}
helloWorld1() method printing Hello World, 'name' using @PathVariable annotation
@GetMapping("/helloworld/{name}")
public HelloWorldBean helloWorl1(@PathVariable String name) {
return new HelloWorldBean(String.format("Hello World, %s", name));
}
Credits
This content originally appeared on DEV Community and was authored by Atharva Siddhabhatti
Atharva Siddhabhatti | Sciencx (2021-08-22T13:52:59+00:00) Hello World in Spring Boot. Retrieved from https://www.scien.cx/2021/08/22/hello-world-in-spring-boot/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.