Introducing To Spring Boot
Introducing To Spring Boot
Spring has been a great framework for years however it had few drawbacks. In this tutorial, An
Introduction to Spring Boot we will see how Spring Boot has not only addressed the drawbacks
but also supports modern software architecture. Spring Boot is around for sometime now.
Spring Team has released one of major innovation on the top of existing Spring Framework is
Spring Boot. It is a completely new project from Pivotal Team (The Spring Team). Spring Boot is
their latest innovation to keep up to date with the changing technology needs. The primary
motivation behind developing Spring Boot is to simplify the process for configuring and
deploying the spring applications.
Spring Boot offers a new paradigm for developing Spring applications with minimal friction.
With Spring Boot, you’ll be able to develop Spring applications with more agility and be able to
focus on addressing your application’s functionality needs with minimal (or possibly no)
thought of configuring Spring itself. It uses completely new development model to make Java
Development very easy by avoiding some tedious development steps and boilerplate code and
configuration.
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications
that you can “just run”. We take an opinionated view of the spring platform and third-party
libraries so you can get started with minimum fuss. Most Spring Boot applications need very
little Spring configuration.
You can use Spring Boot to create Java applications that can be started using java -jar or more
traditional war deployments. We also provide a command line tool that runs “spring scripts”.
Spring Boot automatically configures required classes depending on the libraries on its
classpath. Suppose your application want to interact with DB, if there are Spring Data libraries
on class path then it automatically sets up connection to DB along with the Data Source class.
Spring Boot Primary Goals
Spring Boot primary goals are:
➢ Provide a radically faster and widely accessible getting started experience for all Spring
development.
➢ Be opinionated out of the box, but get out of the way quickly as requirements start to
diverge from the defaults.
➢ Provide a range of non-functional features that are common to large classes of projects
(e.g. embedded servers, security, metrics, health checks, externalized configuration).
➢ Absolutely no code generation and no requirement for XML configuration, to avoid XML
Configuration completely
➢ To avoid defining more Annotation Configuration(It combined some existing Spring
Framework Annotations to a simple and single Annotation)
➢ To avoid writing lots of import statements
➢ To provide some defaults to quick start new projects within no time.
Similarly, Spring Boot doesn’t implement any enterprise Java specifications such as JPA or JMS.
For example, Spring Boot doesn’t implement JPA, but it does support JPA by auto-configuring
the appropriate beans for a JPA implementation (such as Hibernate) finally, Spring Boot doesn’t
employ any form of code generation to accomplish its magic. Instead, it leverages conditional
configuration features from Spring 4, along with transitive dependency resolution offered by
Maven and Gradle, to automatically configure beans in the Spring application context.
In short, at its heart, Spring Boot is just Spring.Future Spring projects would not have any XML
configurations as part of it, everything will be handled by the project Spring Boot.
We can use Spring Boot CLI or Spring STS IDE or Spring Initializer Website to develop Spring
Boot Groovy Applications. However, we can use Spring STS IDE or Spring Initializer Website to
develop Spring Boot Java Applications.
Anyhow, Groovy is also JVM language almost similar to Java Language. We can combine both
Groovy and Java into one Project. Because like Java files, Groovy files are finally compiled into
*.class files only. Both *.groovy and *.java files are converted to *.class file (Same byte code
format).
Spring Boot Framework Programming model is inspired by Groovy Programming model. Spring
Boot internally uses some Groovy based techniques and tools to provide default imports and
configuration.
Spring Boot Framework also combined existing Spring Framework annotations into some simple
or single annotations. We will explore those annotations one by one in coming posts with some
real-time examples.
Spring Boot Framework drastically changes Spring-Java Based Applications Programming model
into new Programming model. As of now, Spring Boot is at initial stage only but future is all
about Spring Boot only.
1. Download the binary distributions for this project from here. Spring Boot CLI requires Java JDK
v1.6 or above in order to run. Groovy v2.1 is packaged as part of this distribution, and therefore
does not need to be installed (any existing Groovy installation is ignored)
2. If you unpack the zip file, you will find spring.bat which will check the all the settings. This script
can be found under the directory /bin.
Cloud Support
Spring Boot provides cloud support for configuration, tools and clients. It’s also compatible with
Cloud Native and works seamlessly with Cloud Foundry, Pivotal etc.
• You can use spring initialize to create the initial setup. You can visit either start.spring.io
or use STS (Spring Tool Suite) Support available in IDEA or Eclipse to choose all the
Spring Boot Starters
• You need to also choose whether to use Maven or Gradle as the build tool.
• If you are using start.spring.io, you need to then download the zip and configure your
workspace. Otherwise using your preferred IDE will automatically create the required file
in the workspace.
• Add your code as required
• You can either use mvn clean package or use IDEA or Eclipse to build and create the
jar file.
• By default the JAR would include integrated Tomcat server, so just by executing the JAR
you should be able to use your program.
Disadvantages of Spring Boot
Migration Efforts
Migration from already existing spring project to spring boot is not straightforward. Spring Boot
is mostly for new development project.
Deploying Spring Boot application to WebSphere/WebLogic Servers are also not very simple.
You need to make few changes like downgrading JPA Version, remove conflicting Jars etc in
order to make it work in WebSphere/WebLogic Application Server.
Spring Boot has been developed keeping Micro services& Cloud Native in mind. You may not
see improvements in other areas.
NOTE:
→SpringBoot starter <parent> will do following things finally based on it’s version specifies
other compatable versions like java,UTF and etc.
→downloads some maven or gradle plugins as discussed above that are required to run the
application.
→specifies the versions of the jars that should come based on the <dependency>tags that are
added.
In every springBoot project we must import one parent project that is spring-Boot-starter-parent
it will give following things from central repository to multiple springBoot projects(child
projects)
The above springBoot starter parent automatically configurations the following plugings.
Maven-failsafe- plugin,maven-jar-plugin,maven-surefire-plugin.
@@EnableAutoConfiguration(based on jar files and user defined beans that are placed in
application it tries configure some predefined bean automatically)