Spring Initializr

Learn via video courses
Topics Covered

Overview

Spring Initializr is a Web-based tool that generates the Spring Boot project structure. Spring initializer helps the developers generate skeleton projects quickly to start spring boot.

Introduction to Spring Initializr

Spring Initializr is a Web-based tool that generates the Spring Boot project structure. Spring boot projects can be set up manually. Still, It is very easy for the developers to select the necessary configuration for their projects with the help of a spring initializer.

We can access Spring Initializr from start.spring.io.

Spring Initializr Modules

Spring Initializr has the following module:

  • initializr-actuator: optional module to provide additional information and statistics on project generation.
  • initializr-bom: provides a Bill of Materials for easier dependency management in your project.
  • initializr-docs: documentation.
  • initializr-generator: core project generation library.
  • initializr-generator-spring: optional module defining the conventions for a typical Spring Boot project. It can be reused or replaced by your conventions.
  • initializr-generator-test: test infrastructure for project generation.
  • initializr-metadata: metadata infrastructure for various aspects of the project.
  • initializr-service-sample: showcases a basic custom instance.
  • initializr-version-resolver: optional module to extract version numbers from an arbitrary POM.
  • initializr-web: web endpoints for third-party clients.

Ready to supercharge your Java applications? Enroll in our FREE Spring Boot course and become a proficient Spring Boot developer today!

Generating a Project with Spring Initializr

The web user interface of the spring initializer looks like this:

spring-initializer

To generate a project, the following inputs are to be supplied.

  • Project - This allows the users to create either a Maven or Gradle Project.
  • Language - Language can be chosen from; Java, Kotlin, and Groovy.
  • Spring Boot - Here, we can select the Spring Boot version.
  • Project Metadata - This contains information that describes the project. We are provided with the following fields to set our project description:
    • Group: It sets the name of the package.
    • Artifact: It sets the Application name.
    • Name: It is the same name as the Application name.
    • Description: This field is used to describe the project.
    • Package name: It is also similar to the Group name.
    • Packaging: We can choose either Jar or War to pack our project.
    • Java: We can choose the JVM version here.
    • Dependencies: Dependencies are the pieces of software that the current project needs to compile, build, and run. Spring boot offers dependencies using starters. List of dependencies offered by spring boot:

spring-initializr-projects

Finally, the Generate button starts building the project, which gets downloaded with the same click.

Spring Initializr in Visual Studio Code

Going to the web and generating a project works fine; however, all the IDE support spring initializers. We will cover the steps to generate a spring boot project using visual studio code.

  1. Install the plugin in VS code Install Spring Initializr Java Support plugin.

spring-initializr-java-support-plugin-in-vscode

  1. Create a new project Now we have the plugin installed. To create a new initializer-based project, press ctrl+shift+P to open the command palette and type spring init. You should see options "Create Gradle project" and "Create maven project". Choose either of them based on the build tool configured in your system.

create-project-spring-initializr

  1. Select the spring boot version The wizard will ask for the spring boot version in the next step. Select appropriate version

spring-boot-version

  1. Select other meta information Wizard will ask you for all the information visible on the starter web page. Once all the details are provided, it should generate a project in IDE.

project-on-ide

Spring Boot Initilizr With Spring Boot CLI

Many developers prefer to work with the command line. Spring boot project can be generated using the command line using spring boot CLI.

Use the spring init command on spring CLI to generate the project.

If the command is successful, it should show the below output on the console.

Conclusion

  • Spring initializer saves the trouble of configuring the skeleton spring project.
  • Spring skeleton project can be generated from the web interface start.spring.io.
  • Spring skeleton project can be generated from all the IDEs directly
  • For developers who want to work with the command line, a skeleton project can be generated using spring boot CLI.