Spring Initializr provides a simple and intuitive web UI to create and configure and generate Spring based applications. This tool makes it easy for developers to generate an initial project structure without worrying much about the project structure and dependencies. On a high-level Spring Initializr tools take cares of the following points for any Spring based application
- Project structure.
- Dependencies required to start the work.
- build script (Maven or Gradle) to build the application.
- Language and version (Initializr will add correct dependencies based on the version)
- packaging (war or jar)
Spring Initializr is available on the web, most of the IDE has built-in integration with the Initializr.
2. Spring Initializr
Let’s look at the Initializr interface to start with. Go to start.spring.io, you will have a similar screen.
This is the simplest Initializr view with minimal options to build your project. Let’s quickly discuss these fields for a basic understanding.
- Project – This gives us the option to select the project as Maven or Gradle based. In this post, we choose Maven. This selection generates a pom.xml file for our project.
- Language – The programming language to use (We chose Java). You have the option to select Groovy or Kotlin.
- Spring Boot – Spring Boot version.
- Project Metadata
- Group – The
groupIdattribute in Apache Maven, also known as the id of the project’s group.
- Artifact – The name of the project, also known by the
artifactIdattribute in Apache Maven.
- Group – The
- Dependencies – List of the dependencies for your application. We will see the different options under the advanced section. I am selecting “web” as a dependency for this post.
Once you provided these details, click on the “Generate Project” button. Spring Initializr provides a zip file containing a Maven/Gradle project. Below is the structure for our generated Maven project.
3. Spring Initializr Advance Options
Above section describe the least view of the tool, It also offers an advance view of the advanced users. Click on the “Options” link to get this view.
Let’s look at a few of the advanced properties (We already covered a few in Section 1)
- Name – Name of the Project
- Description -Description of the project.
- Package Name – Root package of the project. If not specified, the value of the Group attribute used.
- Java Version – the Java version to use.
Apart from this, Spring Initializr provides a detail view of the dependencies section where we can choose different dependencies required for our application. Here is a partial view of this section.
There are certain use cases when a certain dependency is not available in the given Spring Boot version. If you ever face such an issue, click on the advanced section to see if the required dependency is available in the selected version of the Spring Boot.
3.2 Default Values
This service comes with certain default values to generate a new project with minimum fuss. In case you don’t give these values, the Initializr service will pick these default values while generating your project structure. Here are the default configurations for your reference
- Default language is Java.
- Default build tool is Maven.
- Packaging default to jar
In this post, we discuss different features of the Spring Initializr service. Initializr is a powerful service that helps to create and speed up project bootstrapping by taking out the setup complexities. There is a minimal code involved, and the service has a rich configuration structure, allowing you to define not only the values of various project attributes but also the list of dependencies and the constraints to apply to them.