In this post, we quickly cover the different features of the Spring Initializr tool.
Introduction
Spring Initializr provides a simple and intuitive web UI for creating and configuring and generating a Spring-based application. This tool makes it easier for developers to create an initial project framework without thinking about the framework and dependencies of the project. The High Level Spring Initializr tools take care of the following points for every Spring based application.
⦁ Project structure.
⦁ Dependencies needed to start work.
⦁ Build a script (Maven or Gradle) to build your application.
⦁ Language and version (Initializr adds the correct version-based dependencies)
⦁ packaging (war or jar)
Spring Initializr is available on the web, most of the IDEs have built-in integration with the Initializr.
1. 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 limited choices for building your project. Let’s explore these areas quickly for a basic understanding.
Spring Boot Version – The version of Spring Boot version.
Group – The groupId attribute in Apache Maven, also known as the project group I d.
Artifact – The name of the project, also known as the artifactId attribute in Apache Maven.
Dependency – List of dependencies for your program. Under the advanced portion, we’ll see the various choices. I chose “web” as a dependence for this article.
Generate as – This gives us the option to choose a project based on Maven or gradle. We’re choosing Maven in this article. This selection will generate a pom.xml file for our project.
With – The programming language you choose to use (We picked Java). You have the choice to pick Groovy or Kotlin.
When you have given these information, press the “Generate Project” tab. Spring Initializr includes a zip file containing the project Maven / Gradle. Below is the structure of our created Maven project.
mvnw
mvnw.cmd
pom.xml
src
├── main
│ ├── java
│ │ └── com
│ │ └── onurdesk
│ │ └── first
| | └── FirstApplication.java
│ └── resources
│ ├── application.properties
│ ├── static
│ └── templates
└── test
└── java
└── com
└── onurdesk
└── first
└──FirstApplicationTests.java
Automatically generated above the framework of the tool depending on the selected dependencies. Since we have selected “web” as our dependencies, Spring Initializr has detected that it is a web application, static and template folders generated to contain the static tools and UI models.
Spring Initializr is smart enough to use Maven wrapper in the framework of the project. This wrapper means that we don’t have to install Maven to run this project.
Use the following command ./mvnw install to build and run this application without installing Maven.
Import this project in Eclipse
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
2020-10-22 19:57:19.192 INFO 15900 --- [ main] com.onurdesk.first.FirstApplication : Starting FirstApplication on mayur- lappi with PID 15900 (D:\LearningNewTech\grey\Spring boot\first\target\classes started by onurdesk in D:\LearningNewTech\grey\Spring boot\first)
2020-10-22 19:57:19.199 INFO 15900 --- [ main] com.onurdesk.first.FirstApplication : No active profile set, falling back to default profiles: default
2020-10-22 19:57:23.087 INFO 15900 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-10-22 19:57:23.118 INFO 15900 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-10-22 19:57:23.118 INFO 15900 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.38]
2020-10-22 19:57:23.380 INFO 15900 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-10-22 19:57:23.380 INFO 15900 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4085 ms
2020-10-22 19:57:23.773 INFO 15900 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-10-22 19:57:24.117 INFO 15900 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-10-22 19:57:24.136 INFO 15900 --- [ main] com.onurdesk.first.FirstApplication : Started FirstApplication in 6.194 seconds (JVM running for 7.385)