Develop your first Spring Boot app in 5 mins

In this tutorial, you’ll learn about how can you develop your first Spring Boot app using Spring Initializr.

Spring Initializr is a web-based tool provided by the Pivotal Web Service. With the help of Spring Initializr, we can easily generate the structure of the Spring Boot Project. It offers extensible API for creating JVM-based projects.

Let’us go to the Spring Initialzr web page to start!

Spring Initializr automatically creates the base project for us with selected language, version, and dependencies.
  • Here are two options as “Maven Project” and “Gradle Project”, and I choose “Maven Project”.
  • We have 3 languages: Java, Kotlin and Groovy, and I choose Java.
  • I use 2.5.0 Spring Boot version which is a ultimate stable release that I like most!
Project metadata
  • In project metadata section, we can set our project metadata.
  • There are some specific details like packaging and Java version. I choose Jar and Java 11.
  • In dependencies section you can add dependencies you need!
  • Since we’ll develop a basic rest controller, we added Spring Web as our only dependency.

When you click generate button, our project base version will be downloaded as a zip file. All we need just unzip and then import it on our favorite IDE. I use Eclipse for my Spring Boot developments!

Now, let’s import our project, and here is the way to import it on Eclipse: File -> import -> Maven -> Existing Maven Projects.

File -> import -> Maven -> Existing Maven Projects

After importing the project, maven will download the dependencies automatically to make everything read to run our project! To run project on Eclipse: Right click on the project “helloworld” -> Run As -> Java Application.

Select our project to run.

Since Spring Boot has a built-in server, Tomcat, we don’t need to set up any fancy server. After we run our app, Spring Boot will start Tomcat automatically. Now, you can go to http://localhost:8080/ to check our application! However, when you go to localhost:8080 you’ll see “Whitelabel Error Page” but please don’t worry about it! :)

Whitelabel Error Page

Since we have not coded so far, we got this error. Now, let’s develop a very basic code to print out hello message on our web page! We’ll create a new package for our controller class.

controller package

And, here is given below our basic controller class that faces requests to print out our hello message!

Now, it is time to get hello message from our first Spring Boot Web app! Just let’s run the app and then go http://localhost:8080/ to check our app!

Yes! We did it!

And, yes we did it! So we initilaized project skeleton using Spring Initializr and then write some basic codes to print out text on our web page! Thus, you developed your first web app using Spring Boot! Yay!!

I am a big fan of Real Madric CF and I love computer science!