As We know that the spring boot is the advance feature over the normal spring framework using with maven or gradle. Previously with spring framework there was a lot of configurations were required to perform dependency injections or, mvc (model view controller). All setup was done through by adding spring jar files in project build path.
While doing these configurations basically developers were facing various types of problems like: compatibility issues regarding versions of jar, lack of enough resources of jars, creating project structures, unnecessary dependencies while adding extra jars. Since, those jars were tightly coupled with the application, so developers were facing issues related to compatibility issues and a lot of time
Spring boot has resolved this issue while introducing spring boot initializr.
Basically, spring initializr is the feature provided by spring boot which resolves the problem with respect to project structure. It’s not supporting only for java but also provides the compatibility to develop application using some other language like: Kotlin, Groovy.
Spring boot initializr provided an extensible api to generate QuickStart projects. We can easily create a web application using spring initializr where it populates the structure for the application.
We can start creating spring initializr project by accessing url: https://start.spring.io/
Where we need to provide the metadata of the required application Like: project type (maven/grade), Language, version, Group and artifact details.
Along with this we need to add dependencies which ever required for our project Like: spring security, jpa, jersey etc. All these dependencies will add in pom.xml file.
POM (Project Object Model) is basically called as fundamental unit of work in Maven. It contains the configurations about the project which is basically an XML file. Basically, project configuration definitions added in the form of dependencies with plugins, goals and the build profile. These are the mainly basic configuration which defines in pom.xml.
Now we’ll see how to start our project using spring initializr step-by-step:
- Step-1: Go to the browser and access url: https://start.spring.io/
It’ll look like this where it enables user to create new spring boot project.
- Step-2: Since the site offers all possibilities to configure certain aspects of the project where you ‘ll have to provide your project information Like: Project type, Language, Spring boot version metadata dependencies etc.
Here it’ll provide the developer with various list of required dependencies we need to add as per our project requirement, all we need to add by selecting checkbox(s).
Project : Currently spring boot application provide to facilitate user to create two types of projects: Maven and Gradle.
Language : Basically refers programming languages like: java, groovy or, kotlin
java version : Asked the jdk version which will be the part of build of project.
Packaging : packaging type like: war or, jar file
Group : group is basically groupId of your project.
Artifact : artifact is basically artifactId of the project , basically it will be your project name.
Description : It provide the description about your project.
All these are basically basic information needed to develop your project by using spring boot initializr.
- Step-3: Now when we extract the dependencies part by clicking three dot lines option it allows us to add identifiers of the dependencies to add in our project. Mainly all dependencies categories here according to their categories Like: Developer Tools, Web, Template Engine, Security, Sql and so on.
- Step-4 : Now according to project demand or developer requirements , he/she will be able to choose all required dependencies using this GUI-interface. It allows to add multiple dependencies at a time which will resides in pom.xml file as an XML format like:
- Step-5 : After clicking Generate project , all these information will create Maven project structure and download as a zip file.
- Step -6 : Now after downloading zip file to local system we need to extract it and it needs to import as a maven project in our IDE (Like: Eclipse, STS, IntelliJ , NetBeans (Using NB Springboot plugin).
- Step-7 : Now it will ask about the location where we have extracted the zip file. Since every Maven project will have pom.xml file as root level so we need to select the root folder path. Now it automatically find the pom and Snapshot jar which has build at the time of generating project from spring starter site.
Now, we are able to work with spring boot project using spring boot initializr.
Note: Spring also provide CLI support from command line tools which defines init command that allows you to create project using spring initializr.
Spring Initializr has the following main modules:
initializr-generator: It is standalone project generation library that can be able to reuse in many environments.
initializr-metadata: It contains metadata infrastructure for various aspects of project.
initializr-web: Contains REST-API’s endpoints as well as web interfaces.
initializr-actuator: Basically its an optional module which provide additional information , statistics as well as metrics on project generation.
initializr-docs: contains documentation related to spring boot.