1. HelloWorld Demo - Hello Spring Stack
Contents
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
|
|
Generate a Web Project
Choose the Project Type
|
|
Choose the Language
|
|
Choose the Spring Boot Version
|
|
Provide Group
|
|
Provide Artifact
|
|
After clicking the Generate button, we get the following zip file:
Copy and paste the shop folder to whatever directory you would like to or just place it on the desktop:
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:
Choose the shop folder and click OK:
There might be an message at the right bottom of the IDE showing that IntelliJ is resolving dependencies of the shop project:
After IntelliJ resolved the required dependencies, we’ll see the project content at the top left of the IDE:
Hello Spring Stack
- Go to src > main > java > co.dongchen.shop
- Double click ShopApplication
Add RestController annotation above the ShopApplication class:
|
|
Also add a helloSpringStack() method in the ShopApplication class:
|
|
Verify
Run the App
|
|
Choose the correspondent option and press enter.
Check Application Healthiness in Browser
|
|
The status’s value is UP which means the application is healthy.
View Hello Spring Stack in the Browser
|
|
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
Author Dong Chen
LastMod Wed Apr 24 2019