The Wayback Machine - https://web.archive.org/web/20240606091546/https://www.geeksforgeeks.org/spring-initializr/
Open In App

Spring Initializr

Last Updated : 08 Nov, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Spring Initializr is a Web-based tool that provides simple web UI to generate the Spring Boot project structure or we can say it builds the skeleton of the Spring-based application. The spelling mistake in initializr is inspired by initialize. It provides extensible APIs for creating JVM(Java Virtual Machine) based projects. Spring Initializr is straightforward for the developers to select the necessary configuration for their projects which helps you to customize and configure the project requirement and automatically manage the Spring Boot Dependencies using the Maven repository or Gradle. Modern IDEs have integrated Spring Initializr which provides the initial project structure. The Spring Initializr tool takes care of the following configuration for any Spring-based project. 

Requirement Specification

  • An IDE (Spring Tool Suite(STS), IntelliJ IDEA Ultimate and IntelliJ IDEA Community Edition(Limited Configuration options), Netbeans, and VSCode) OR CLI.
  • Java 17 or later Version
  • Build tool (Maven repository or Gradle repository) to build the application.
  • Spring Boot version (Dependencies are added based on the version)
  • Dependencies required for the project.
  • Project Metadata like name, packaging (Jar or War), package name, etc.

With all the provided information, the Spring Initializr generates the Spring project structure. We can use the Spring Initializr either from the Web or IDE or Command-Line.

Spring Initializr Web

Let us learn how to use the Spring Initializr web UI to generate the Spring Boot project for which the prior step is navigating to start.spring.io to get it. The window that will pop up is depicted below which is as follows:

Spring_initializr

The Spring Initializr UI has the following options,

  • Project: Using this one can create Maven or Gradle project i.e; Maven or Gradle can be used as a build tool. The default option is Maven Project. Maven project is used in the entire tutorial. 
  • Language: Spring Initializr provide Java, Kotlin and Groovy as a programming language for the project. Java is the default option.
  • Spring Boot Version: Using this one can select the Spring Boot version for their project. Spring Boot latest Version is 3.1.5. The SNAPSHOT versions are under development and are not stable.
  • Project Dependencies: Dependencies are artifacts that we can add to the project.
  • Project Metadata: It is the information about the project. 

Information in the metadata does include below key points:

  • Group ID: It is the ID of the project group.
  • Artifact: It is the name of the Application.
  • Name: Application name.
  • Description: About the project.
  • Package name: It is the combination of Group and Artifact Id.
  • Packaging: Using this Jar or War packaging can be selected
  • Generate: When generate option is clicked, the project is downloaded in zip format. The zip file can be unzipped and the project can be loaded into an IDE.
  • Explore: This allows to see and makes changes in the generated project. 

Project Structure – The Spring Boot project looks as follows:

Spring Boot demo project structure

Methods

Spring Initializr can be achieved via two ways which are as follows:

  1. Using IDE
  2. Using Command line

Method 1: Spring Initializr using IDE’s

Spring Initializr is supported by various IDEs like Spring Tool Suite(STS), IntelliJ IDEA Ultimate and IntelliJ IDEA Community Edition(Limited Configuration options), Netbeans, and VSCode.

If you are using Netbeans, Spring Initializr plugin can be added to the IDE.

If you are using VSCode, vscode-spring-initializr plugin can be added to the VSCode.

IntelliJ Community Edition Usage:

Steps to be followed:

  1. Open IntelliJ CE IDE.
  2. Click on New Project.
  3. Select Maven Project and Java JDK Home path
  4. Enter Project Metadata details
  5. Click the Finish button.

Let us pictorially depict the above steps to get a fairer understanding

  • Open IntelliJ CE IDE.
  • Click on New Project.

Click on New Project

  • Select Maven Project and Java JDK Home path.

Select Maven Project and Java SDK path

  • Enter Project Metadata details such as Name, GroupId, ArtifactId.

Enter Project Metadata details such as Name, GroupId, ArtifactId

  • Click the Finish button.

Note: If you are using IntelliJ Ultimate Edition, the steps are available here.

Method 2: Spring Initializr using Command Line

A lot of developers love to do things from the command line. For them, there is an option to create the Spring project using command-line utilities like Spring Boot CLI (Command Line Interface), cURL or HTTPie. To use cURL or HTTPie, one has to install them prior to the usage.

curl https://start.spring.io

The above command will give the entire instructions on how to create a project using cURL.

Spring Initializr using curl

Let’s assume that you want to generate a demo.zip project based on Spring Boot 1.5.2.RELEASE, using the web and developer tools dependencies (remember, those two IDs are displayed in the capabilities of the service):

$ curl https://start.spring.io/starter.zip -d dependencies=web,devtools \
-d bootVersion=1.5.2.RELEASE -o demo.zip.zip

The exact same project can be generated using the HTTP command as well:

$ http https://start.spring.io/starter.zip -d dependencies==web,devtools \
-d bootVersion==1.5.1.RELEASE -o demo.zip

Note: Apart from all these, Spring Initializr teams also provide extensible APIs for creating JVM-based projects. Also, one can create their own instance of Spring Initializr for their own projects. It also provides various options for the project that are expressed in a metadata model. The metadata model allows us to configure the list of dependencies supported by JVM and platform versions, etc.



Previous Article
Next Article

Similar Reads

How to Create a Spring Boot Project in Spring Initializr and Run it in IntelliJ IDEA?
Java language is one of the most popular languages among all programming languages. There are several advantages of using the java programming language, whether for security purposes or building large distribution projects. One of the advantages of using Java is that it tries to connect every concept in the language to the real world with the help
3 min read
How to Generate a New Spring Cloud Project in Spring Initializr?
Spring Initializr is a Web-based tool that generates the Spring Boot project structure. The spelling mistake in initializr is inspired by initializr. Modern IDEs have integrated Spring Initializr which provides the initial project structure. It is very easy for developers to select the necessary configuration for their projects. The Spring Initiali
2 min read
Spring Boot - Spring JDBC vs Spring Data JDBC
Spring JDBC Spring can perform JDBC operations by having connectivity with any one of jars of RDBMS like MySQL, Oracle, or SQL Server, etc., For example, if we are connecting with MySQL, then we need to connect "mysql-connector-java". Let us see how a pom.xml file of a maven project looks like. C/C++ Code <?xml version="1.0" encoding=
4 min read
Difference Between Spring DAO vs Spring ORM vs Spring JDBC
The Spring Framework is an application framework and inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform. Spring-DAO Spring-DAO is not a spring module. It does not provide interfaces or templates
5 min read
Spring vs Spring Boot vs Spring MVC
Are you ready to dive into the exciting world of Java development? Whether you're a seasoned pro or just starting out, this article is your gateway to mastering the top frameworks and technologies in Java development. We'll explore the Spring framework, known for its versatility and lightweight nature, making it perfect for enterprise-level softwar
8 min read
Java Spring Boot Microservices - Develop API Gateway Using Spring Cloud Gateway
The API Gateway Pattern in some cases stands for “Backend for frontend”. It is basically the entry gate for taking entry into any application by an external source. The pattern is going on in a programmer’s mind while they are making the client’s application. It acts as a medium between the client applications and microservices. For example-Netflix
4 min read
Spring Boot | How to access database using Spring Data JPA
Spring Data JPA is a method to implement JPA repositories to add the data access layer in applications easily. CRUD stands for create, retrieve, update, delete which are the possible operations which can be performed in a database. In this article, we will see an example of how to access data from a database(MySQL for this article) in a spring boot
4 min read
Difference between Spring MVC and Spring Boot
1. Spring MVC : Spring is widely used for creating scalable applications. For web applications Spring provides Spring MVC framework which is a widely used module of spring which is used to create scalable web applications. Spring MVC framework enables the separation of modules namely Model View, Controller, and seamlessly handles the application in
3 min read
Spring - Add User Name and Password in Spring Security
Spring Security is a powerful and highly customizable authentication and access-control framework. It is the de-facto standard for securing Spring-based applications. Spring Security is a framework that focuses on providing both authentication and authorization to Java applications. Like all Spring projects, the real power of Spring Security is fou
3 min read
How to Create and Setup Spring Boot Project in Spring Tool Suite?
Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. Spring Boot is a microservice-based framework
3 min read
Article Tags :
Practice Tags :