Spring Boot Hello World Program

Spring Boot is built on top of the Spring Framework. It makes easier and quicker to develop, setup, and run the Spring Boot applications.

Spring Boot is  the combination of Spring Framework and Embedded Servers.

Spring Boot has no requirement of XML configuration.



We can develop our 1st HelloWorld program using the Spring Boot Initializer.

Follow the below Steps To write  the HelloWorld program using Spring Boot:-


Please visit  https://start.spring.io/  .




Choose Java, Maven, and Spring Boot version.

Provide the Group and Artifact Name.

Select Package JAR

and Java -11

Click on add dependency and search WEB


Select Spring Web

Click on the Generate


A zip file will get downloaded. Extract the file.

Open it with any IDE I am using IntelliJ Idea For this project

and run the application.


Spring Boot Use 8080 port by default. You may have to change the port if it is already been used on your PC.

 let's write a class called HelloWorld.



Run the application again.

Code Details.


package com.letustryandlearn.HelloWorld;


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

@RestController
@RequestMapping( path = "/helloworld")
public class HelloWorld {
    @GetMapping(path = "/hello")
    public String getMessage() {
        return "welcome to spring boot";
    }
}

You can hit the URL http://localhost:9090/helloworld/hello
This completes our HelloWorld program using Spring Boot.

LET US TRY AND LEARN

Author & Editor

0 Comments:

Post a Comment