History of Spring Boot
Before Spring Boot enterprise-level development creating an application with the Spring framework was so difficult. As a developer, you have to create and maintain the dependence injection, web configuration, deployment and etc. This also increase the learning curve for the developers.
Mike Youngstrom opened Spring JIRA # SPR-9888 feature JIRA on 17th Oct 2012. The idea was to reduce the learning curve of any new developer who will be coming in to create application using Spring's Web Application.
What is the Spring Boot?
Spring framework provides a pre-setup of Spring and some third party library using which developer could develop an application without any/much of configurations result in faster development. Non-functional features are readily available such as an embedded server, health check, security, metrics, and externalised configuration. If we want to differ from Spring-provided default configurations we could simply do so.
Spring Boot application could be bundled into a jar or a traditional war, as a result, it is easy to deploy. It also provides a command-line interface (CLI) to run the Spring script.
Why anyone uses Spring Boot?
- Do prototyping.
- Creating a minimum viable product for the actual market.
- Create Microservice
How to use/implement Spring Boot?
Spring Boot requirements
- Java 8 onwards supported
- Maven 3.3+ version build tool supported
- Gradle 6.3+ version build tool supported (5.6.x is also supported but is deprecated form)
- Tomcat 9.0 embedded servlet container (Servlet 4.0) supported
- Jetty 9.4 embedded servlet container (Servlet 3.1) supported
- Undertow 2.0 embedded servlet container (Servlet 4.0) supported
You can also deploy Spring Boot applications to any Servlet 3.1+ compatible container.
Spring Boot is available in Groovy or Kotlin or Java language for application development.
To minimise the developer’s effort Spring provide Spring Initializr (https://start.spring.io/) to generate the basic structure of your project with all the dependency in it. The Spring Boot Command Line Interface (CLI) is a command-line tool that you can use to quickly prototype an application. As it uses Groovy script for it, which means there is no boilerplate code that still has flour of Java.
Creating a simple application
Open Spring Initializr (https://start.spring.io/) to generate the basic structure of your project with all the dependency in it.
This will create the basic project structure.
pom.xml which is generated from Spring Initializr (https://start.spring.io/).
Note all the official starters follow the naming pattern spring-boot-starter-*
It has a spring-boot-starter-parent parent. We included only Spring Web and Spring Initializr add the test for unit testing. We will see how to test Spring Boot in another blog.
The main class generated by Spring Initializr
Created a controller to make REST call
RequestMapping maps HTTP requests to handler methods of MVC and REST controllers