Spring Boot
Table Content
1. Spring framework
2. What is Spring Boot
3. Features of Spring Boot
4. Creating Spring Boot Application
Spring Framework
Spring Framework is an open source application framework created by Rod Johnson in 2003.
It a lightweight solution for enterprise applications.
Spring framework is said to be a non-invasive.
it is modular and extendible for other frameworks.
Spring is really a great framework but it has some few pitfalls.
1. Spring configuration represents development friction :
Spring required a lot of configuration either in the form of XML configuration, or java configuration. So developer efforts required
to think about configuring a Spring distracts from solving the business problem.
2. Dependency management is another form of friction :
It can be challenging to add dependencies to a project’s build. What library do you need? What are its group and artifact? Which
version do you need? Will that version play well with other dependencies in the same project?
Spring Boot has changed all of these.
What is Spring Boot
Spring Boot is build on the top of the Spring Framework for developing Spring applications with no configuration.
It is an amazing technology that is suitable for :
Enterprise Production Ready Spring applications.
Better productivity by reducing time of development and deployment.
Cloud native applications that follow the 12 factor patterns developed by the Netflix engineering team.
Non-functional requirements, like the Spring Boot Actuator ( a module that provides metrics with the new platform agnostic
Micrometer (https://micrometer.io), health checks, and management)
Embedded containers for running web applications (Tomcat, Jetty, etc.).
Microservices, which are getting attention for creating scalable, highly available, and robust applications.
Spring Spring XML Embedded Spring Boot Spring Boot
Boot Framework configuration Server Starter Actuator
Features of Spring Boot
1. Automatic configuration :
Spring Boot can automatically provide configuration for application functionality common to many Spring applications.
Spring Boot detects that if we have the H2 database library in our application’s classpath, it will automatically configure an
embedded H2 database. If JdbcTemplate is in the classpath, then it will also configure a JdbcTemplate bean for us. There’s no need
to worry about configuring those beans.
2. Starter dependencies :
Starter dependencies are just special Maven (and Gradle) dependencies that take advantage of transitive dependency resolution
to aggregate commonly used libraries under a handful of feature-defined dependencies.
No need to think about what libraries you’ll need to support certain functionality.
No need to worrying about which versions of these libraries you need.
3. The command-line interface :
This optional feature of Spring Boot lets you write complete applications with just application code, but no need for a traditional
project build.
4. The Actuator :
Gives you insight into what’s going on inside of a running Spring Boot application.
Creating Spring Boot Application
Basically, there are following three ways in which we can create Spring Boot Project.
1. Using Spring.io initializer
2. Using Spring Tool Suite
3. Using CLI
1. Using Spring.io initializer
Open URL: http://start.spring.io/
Here, we can select Project type
wither Maven or Gradle, Spring
Boot version and project meta
data.
We can also select all the
dependencies which we have
currently in mind, and generate
the project.
Generate Project button will
generate a .zip file. Download
and extract the file into your
workspace.
Next step is to import the
generated project into your IDE.
After import into eclipse Run
the main class.
Import as a maven project into eclipse and run the application. Application is running on embedded tomcat server at 8080 port.
2. Using Spring tool suite
Open the Spring Tool Suite and then Select the New Spring Starter Project menu item
from the File menu. When you do, Spring Tool Suite will present you with a dialog box as
below.
As you can see, this dialog box asks
for the same information as the
web-based
Spring Initializer.
In fact, the data you provide here
will be fed to Spring Initializer to
create a project zip file, just as
with the web-based form.
Enter all the details and click on Next button.
After click on next button below screen will appear.
Here we can select all the dependencies which we required for our project.
Click on finish.
When we click on Finish button, project generation and import process will start.
Now we can run our application with an embedded server by selecting Run As Spring Boot Application from the Run menu.
3. Using CLI
First of all we need to install Spring Boot CLI.
We can download the distribution archive from either of these locations:
http://repo.spring.io/release/org/springframework/boot/spring-boot-cli/1.3.0.RELEASE/spring-boot-cli-1.3.0.RELEASE-bin.zip
Now unzip it, and add its bin directory to our system path.
Now we’re ready to use the Spring Boot CLI.
The Spring Boot CLI includes an init command that is used to create a baseline Sprin Boot project:
$ spring init
If we want to start out by building a web application that uses JPA for data persistence and that’s secured with Spring Security. We
can specify those initial dependencies with either --dependencies or -d:
$ spring init -dweb,jpa,security
This will give us a demo.zip containing the same project structure
Now we can import this project into eclipse and run the application.
Thank You