This will be a short post more focused towards introducing Spring Boot, We will discuss “What is Spring Boot“? and how Spring Boot is helpful in building Java based enterprise applications.
As a Java developer, it’s very likely that we have worked with Spring Framework based application directly or indirectly.Spring has a number of ways to configure its behavior, it provides the option to use XML based configurations or to use Annotations, JavaConfig is becoming the de facto standard for the new Spring based applications.Although these options seem really good, with large enterprise applications involves hundreds of modules and complicated business rules, these configurations can become really complicated. Below are some of the complications which large application can bring in to the picture
Spring 4.x to 5.x) will be complicated as we need to ensure that all required dependencies are upgraded correctly.
All above issues are more or less related to making sure we have everything before dev team can start working on actual tasks. Now let’s talk about another use case which we use to do with any Spring based application, Let’s say we want to create a web-based application, these are most common steps most of us will be doing on regular basis
ViewResolver, MessageSource etc.
This list can grow significantly based on type of our application
All of the above steps seem very to us but they add a lot of overhead to the development team and instead of focusing on solving the actual business problem, initial time will be consumed to ensure that everything is in the correct place to start work. Think of Spring Boot as a tool which can do these initial tasks for us automatically.Spring Boot works on an opinionated view of the Spring platform being used by us and ensures that team can quickly start working on solving the actual business problem rather than spending time on the initial configurations and setup.
Spring Boot provides the following feature out of the box
XML configurationsfor your project.
Maven POMto simplify your configuration
Using Spring Boot, it’s easy to manage and handle issues highlighted in the introduction section. .We are not required to manually search for compatible jars during upgrade, Spring Boot will ensure that our application is upgraded to the correct version (This is called working on application with minimum fuss)
Let’s take a look at a sample
pom.xml for our web application to get an understanding of sample Spring Boot configuration
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.javadevjournal.demo</groupId> <artifactId>sample web application</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.7.RELEASE</version> </parent> <name>rWeb Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-hateoas</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies> </project>
Just pay close attention to
<packaging> tag, Spring Boot provides flexibility to run our application as a
jar and not forcing us to use
war as required packaging type.
Just check configuration closely and you won’t be finding any entry for all those Spring dependencies (like web
MVC, core, AOP, ORM, Validation API etc.), you might have noticed similar entries
spring-boot-starter-*, this is Spring Boot dependency management process. We have added
spring-boot-starter-web to our
pom.xml and Spring Boot will pull all required dependencies for
Spring MVC application (no more manual configurations).
Auto Configuration is another interesting feature of Spring Boot this is why Spring Boot team say’s that it has opinions.These are some of work Spring Boot will do for you
Read our article on to get the in-depth understanding of Spring Boot Auto Configurations.
Do you recall that process of deploying your application on the Servlet container (Tomcat etc.), every time we make those small changes and require to deploy those into the app server to test our changes? Spring Boot provides support for embedded Servlet container and we are no longer require to deploy our application on app server (This can be run easily using standard main method) but at the same time we can access our application on the browser using http://<host>:<port>
Spring-boot-starter-web entry in our
pom.xml will provide embedded servlet container for our web application, Apache Tomcat is the default servlet container provided by Spring Boot, however, Spring boot provides ways to use other servlet containers (all we have to add the required starter for this).
Read our post Building an Application with Spring Boot to start building your application with Spring Boot.
In this post, we get an understanding of the Spring Boot, we covered What is Spring Boot? and what are the Benefits of Spring Boot? We discussed different features of the Spring Boot. Spring Boot internally does a lot of things for us which seems to magical to us. In this series, we will be uncovering all these internal details of the Spring Boot.
Hello!! I am Umesh- an engineer by profession and a photographer by passion.I like to build stuff on the web using OSS and love to capture the world through my lens.
Introduction to Spring Boot GraphQL16 Nov, 2018
Testing in Spring Boot04 Sep, 2018
Change the default port in Spring Boot30 Aug, 2018
Spring Boot Whitelabel Error Page14 Aug, 2018
Spring RequestBody and ResponseBody Annotations09 Aug, 2018
Shutdown a Spring Boot Application