Spring Boot!!!!! WHAT & WHY?
Spring boot helps developer to concentrate more on Business
logic than configurations.
If you have developed application in traditional way you
would understand the pain of building project adding dependencies.
How it Assists or Why its Popular ?
Lets discuss some of the features or why to use Spring Boot.
1. Managing the dependencies made easy.
As I said above in old applications if you need to add jars
it was not so easy task because other dependent jars would trouble you.
This was simplified here by just adding starters
Something it looks like this
Spring-boot-starter-*
Where * can be any dependencies like
Spring-boot-starter-web ->This
commonly used for Spring MVC.
Spring-boot-starter-jpa ->
This pulls jpa + hibernate .
So on…
It looks like this :
Pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
</parent>
2.Almost made zero configuration.
Spring-boot-starter-* will not only add dependencies but also
configures commonly registered bean like Dispatcher Servlet, Resource handler,
Message source etc.
This was mainly introduced to achieve Boiler plate config by
automatic configuration of registering beans.
Registering beans based on
- · Class should be available in particular path
- · Presence or absence of bean.
- · Presence of System properties.
- · Absence of configuration file.
3.Spring boot has Embedded Servlet container.
No need to do any extra configuration for servlet container
like traditional way just add -web in starter then spring-boot-starter-tomcat
automatically pulled it has embedded container.
4.Actuator
Key features provides several web end points.
By Actuator you can find out how beans are wired through
spring application context
Spring-boot-starter-actuator to be added in pom.xml
Some of them listed below
/health :
This is get method which displays health of application
/env :
This is get method which displays health of environment properties.
/shutdown :
This is post method which shutdowns the application.
FAQs:
1.For Datasource, EMF transaction manager beans automatically created HOW???
Ans: If we have in memory D.B driver like H2 or HSQL
automatically creates in memory data source and do automatically with sensible
defaults
2 How connection established for Mysql ?
Ans: App.properties files will have connection. Boot creates
Data Source with this properties.
3.How it has Embedded Servlet Container?
Ans: Spring-boot-starter-web
When web is added
then spring-boot-starter-tomcat is automatically pulled. It has embedded
container.
4.How to change to jetty server instead of tomcat?
Ans: Exclude Spring-boot-starter-tomcat and include
Spring-boot-starter-jetty
5.What is Fat jar
Ans: Spring-boot-maven plugin creates single deployment unit
which runs in production without IDE that’s nothing but fat jar.
0 comments:
Post a Comment