Let’s use the spring initializer web features provided by the spring website to generate a super-simple hello world project.

Generate a Project from Official Website

Visit the Spring Initializer Page

1
https://start.spring.io/

Generate a Web Project

Choose the Project Type

1
Maven Project

Choose the Language

1
Java

Choose the Spring Boot Version

1
2.1.x

Provide Group

1
co.dongchen

Provide Artifact

1
shop
img

After clicking the Generate button, we get the following zip file:

img

Copy and paste the shop folder to whatever directory you would like to or just place it on the desktop:

img

Working with IntelliJ

You can use any of the following IDEs

I’ll use IntelliJ IDEA for this project and the up coming projects as well.

Open the Folder

Click on open option:

img

Choose the shop folder and click OK:

img

There might be an message at the right bottom of the IDE showing that IntelliJ is resolving dependencies of the shop project:

img

After IntelliJ resolved the required dependencies, we’ll see the project content at the top left of the IDE:

img

Hello Spring Stack

  • Go to src > main > java > co.dongchen.shop
  • Double click ShopApplication

Add RestController annotation above the ShopApplication class:

1
@RestController
img

Also add a helloSpringStack() method in the ShopApplication class:

1
2
3
4
@RequestMapping("/hello-spring-stack")
public String helloSpringStack(){
  return "Hello Spring Stack";
}
img

Verify

Run the App

1
2
// Short Cut for "Run the Program"
Alt + Shift + F10
img

Choose the correspondent option and press enter.

Check Application Healthiness in Browser

1
http://localhost:8080/actuator/health
img

The status’s value is UP which means the application is healthy.

View Hello Spring Stack in the Browser

1
http://localhost:8080/hello-spring-stack
img

Congratulations! Now we have completed our first program.

References Spring Initializer: Bootstrap your application, Spring Tool Suite, IntelliJ IDEA, Eclipse IDE for Enterprise Java Developers

Buy me a coffeeBuy me a coffee