Creating hello world spring-boot Application

There are lots of people recently working either on developing spring-boot based application or there are people who works on devops and pipeline automation or system side of the same technology. As is, few people will be new to these technologies. So, I am just creating a series of articles on how to create, deploy and automate the deployments.

This is the first in the item as how to create a simple project which you can start using or you can deploy. The base is same if you use this project or any other spring-boot project.

As a first step, you can create a demo project from Spring initializr . Below is the demo as how I filled. Remember to add ‘Spring Web’ dependency. Once you filled out, Click on Generate, and the project will be downloaded. Extract the zip and open the folder with IntelliJ or any supportive IDE.

It may take 1 or 2 mins to load in IDE, as it will download all dependencies when opening for first time.

We have the project now. If you run command — ./gradlew bootRun , the project will start. If you navigate to — http://localhost:8080/ in your browser, it will load to a default spring page. That’s it. You have done it.

You can either create the project or download the project from following GitHub link

You can add an API to return some valid text, so that it will be kind of standard.

Create a file where you have your main class and add below code to it.

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorldController
{
@RequestMapping("/hello")
public String hello()
{
return "Hello world!";
}
}

Now if you navigate to: http://localhost:8080/hello , you will see the app returning “Hello world!”.

Start-up and tech enthusiast. I write about Tech, Devops and anything related.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store