Another Way to say ‘Hello World’ with Spring Boot

Maikel Chandika
Aug 24, 2017 · 2 min read

This is my first post with this cool demanding blog platform. As conventional programmer, it always start with the famous one, the hello world Project :)

Recently I do research and learn about Spring Framework, particularly on its latest version (5.0.0M3) and Spring Boot. Except, you are experience user to this framework, this is another way to give a try, one of the simplest. Moreover, a little bit awesome, and less common.

Preparation

Extract/uncompress the Spring Boot CLI, from command line or terminal, go to its bin folder. Type spring --version , the feedback should be:

Hello World Project

Now we want to create simple web service which is return Hello World . The conventional way to start the Spring Boot project is by create the project files through Spring Initializer. Instead of those, this approach is going to use the groovy script, it quite similar to Java, except less boilerplate code. Furthermore, these methods are usually used for quickly prototype with Spring.

Create a new file, name it Hello.groovy , here the script:

@RestController
class Hello {
@RequestMapping("/")
String index() {
"Hello World :)"
}
}

To run the file, in command line/terminal type spring run <the-file-location> as shown below:

Make sure you have a proper Internet connection. Because Spring need to download the related dependencies. After that give a try by access to http://localhost:8080 from web browser.

Congratulations, you have done to say Hello World with Spring Boot.

)

Maikel Chandika

Written by

Professional Java Developer

Kongkow IT Medan

Komunitas IT kota Medan dan sekitarnya.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade