Spring Boot

Spring Initializr Explained

Posted On
Posted By admin

The Spring Initializr is a web-based service that can help you get started with Spring Boot easily. In this article, I will be explaining what Spring Initializr is and how you can you it.

What is Spring Initializr?

The Spring Initializr is a web-based service provided by the makes of Spring. You can access it from https://start.spring.io/. 

This helps you create a ready to use project structure for a basic Spring Boot application. You can directly use this project structure and add your code.

 

How to use Spring Initializr?

First, you need to select the appropriate values and create the project structure. Next, you need to use the project structure in your IDE.

Creating Project Structure

Step 1 – Go to https://start.spring.io/. You will see a screen as follows:

How to use Spring Initializr

Step 2 – Select values for the type of project, programming language and Spring Boot version. Here, I will be creating a Maven Project in Java with 2.3.0 version of Spring Boot. So I will select the following:

How to use Spring Initializr

Step 3 – Customize the project metadata. So I’ve set the values as follows: I’ve also selected “Java 8” as the Java version:

How to use Spring Initializr

Step 4 – You can also add some dependencies if you want as follows.

Step 4a – Click the add dependencies button as follows:

 

How to use Spring Initializr

Step 4b – This displays the following screen. Here you can click on the necessary dependencies:

How to use Spring Initializr

Step 4c –  Once you click on the dependency, it will show the following screen. So here, I’ve selected the “Spring-web” dependency:

How to use Spring Initializr

 

Step 5 – Finally, click the “Generate” button. This will download the project structure for you:

How to use Spring Initializr

Using the Project Structure

Step 1 – Unzip the downloaded file into any folder. It will display the following project structure:

How to use Spring Initializr

Step 2 – Import this as a Maven project in your IDE. I am using Eclipse. So this creates an Eclipse project as follows. The pom file has some default dependencies as well as the additionally selected dependencies:

How to use Spring Initializr

A demo application is also created for you as follows:

How to use Spring Initializr

Step 3 – Add your code. Let’s add a REST controller that returns “Hello World”:

How to use Spring Initializr

Step 4 – Run the “HelloWorldDemoApplication” as a Java application:

How to use Spring Initializr

Step 5 – Open a browser window and type “http://localhost:8080/hello”. This displays the following:

How to use Spring Initializr

Conclusion

So in this article, we saw how to use Spring Initializr. We saw how Spring Initializr creates a ready to use project structure that you can use in your application

If you like this post, please do let me know via the comments box below.  You can also connect with me via my Facebook Page or subscribe to my Youtube channel!

Related Post

leave a Comment