Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
How To Create A Spring Boot Project?
3.
Creating A Spring Boot Project Using Spring Initializr
4.
FAQs
5.
Key Takeaways
Last Updated: Mar 27, 2024

Spring Initializr

Author Rajat Agrawal
0 upvote
gp-icon
Basics of Javascript
Free guided path
10 chapters
68+ problems
gp-badge
Earn badges and level up

Introduction

Spring Boot is an open-source Java-based framework used to spring boot-microservices. It is used to create stand-alone and production-ready spring applications. It provides an easier and faster way to set up, configure, and run simple and complex web-based applications.

Spring Initializr is a web-based tool used to create the structure of the Spring Boot project.

Let’s now understand different ways of creating a Spring Project.

How To Create A Spring Boot Project?

There are four basic ways to create a Spring Boot project:

1.) Create a Maven project and add starter dependencies.

2.) Using Spring Initializr.

3.) Using Spring Tool Suite(STS) IDE.

4.) Using Spring Boot command-line interface.

One of the suitable ways to start a spring boot project is using Spring Initializr with any of the recommended IDE.

Let’s now understand how to create a spring boot project using Spring Initializr and Eclipse IDE.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Creating A Spring Boot Project Using Spring Initializr

Let’s understand step by step how to create a spring boot project using Spring Initializr and Eclipse IDE.

We have divided the whole project creation process into two Parts. The first part will cover the Spring Boot project structure creation using Spring Initializr, and the second part will cover the testing and running of the Spring Boot project in Eclipse IDE.

Part 1: Creating The Project Structure

Step 1: We can use the Spring Initializr either from the website, Command-Line, or IDE.

One of the easiest ways to use Spring Initializr is through the Web. 

You can go through the link given below to create the project structure.

Visit: https://start.spring.io/

Step2: After visiting the above link, an interface will open, like below.


There is some information that you need to fill in to create the project structure:

1.) Project: It defines the kind of project. You have given two choices to choose the type of project management tool you want to use. We can create either Maven Project or Gradle.

2.) Language: It provides the choice among three languages Java, Kotlin, and Groovy. Java is by default selected.

3.) Spring Boot: Version of Spring Boot you want to work with. The most stable version is selected by default.

4.) Project Metadata: Here, we need to fill in the basic information about the project like project name, artifact, etc.

     1.) Group: Group denotes the package name. By default is com.example. We can change the group id to something else.

     2.) Artifact: Artifact denotes the Application name.

     3.) Name: In this field, you have to specify the name of your project. It is filled by default while filling the Artifact field.

     4.) Description: Put the description of the project here.

     5.) Package Name: It is the same as the Group name.

     6.) Packaging: We can select Jar or War as our package. The Jar is by default selected. 

     7.) Java: Here, we can select the Java version. Select the version which is supported in your system.

5.) Dependencies: You can choose the different dependencies you want to inject into your project. For example, if you build a web application, you can select the Spring Web dependency.

We have added the Spring Web dependency into our project.

We have filled all the required fields, like below.

Step 3: After filling all the fields, click on the Generate button to create the project.

The project structure is given to you in the form of a zip file.

You need to extract that zip file to see the whole project structure.

Now we have completed Part 1 of our project creation process. In the next part, i.e., Part 2, we will see how to integrate these folders and files with our Eclipse IDE to run the Spring Boot project finally.

Part 2: Testing and Running the Spring Boot project in Eclipse IDE.

Step1: Open the Eclipse IDE go to the File menu->Import->Maven select the Existing Maven Projects an interface will open, like below.

In the Root Directory, we need to mention the project path we created with the spring initializr. The path should be the root directory of the src folder. 

Step 2: After choosing the correct path, click on the Finish button, and the whole project structure will open on the left side of the workspace, like below.

The main project folder (CodingNinjas here) contains many folders and files.

Some Important Files and Folders are:

1.) pom.xml: This file contains the information about our project & all the dependencies which we have currently injected.

2.) applications.properties:  This file resides inside the src/main/resources folder and is used to specify various properties of the project. For example, We can specify the port number on which our application runs.

Step 3: Now, to run your application, you can go into the src/main/java->com.packagename->App.java 

In our case it is: src/main/java->com.codingninjas->CodingNinjasApplication.java

Step 4: Right-click on App.java (CodingNinjasApplication.java hereand Run as Java Application.

You can see your application is running on default port 8080, like below.

We have successfully created our Spring Boot project using Spring Initializr and Eclipse IDE.

Recommended Topic, spring mvc vs spring boot

FAQs

  1. What are the different ways to use Spring Initializr?
    We can use the Spring Initializr either from the Website(https://start.spring.io/) or Command-Line or IDE.
     
  2. What is the use of a pom.xml file?
    This file contains the information about our project & all the dependencies which we have currently injected into the project. 
     
  3. What is the use of the applications.properties file?
    This file is used to specify various properties of the project. For example, We can specify the port number on which our application runs.

Key Takeaways

In this blog, we have learned about Spring Initializr, different ways to create a Spring Boot project, and how to use Spring Initializr to create a Spring Boot project.

You can also consider our Spring Boot Course to give your career an edge over others.

Happy Learning!

Next article
How to Download and Install STS IDE
Guided path
Free
gridgp-icon
Basics of Javascript
10 chapters
68+ Problems
gp-badge
Earn badges and level up
Live masterclass