Spring Boot
Spring Boot
Spring
Dependency Injection Framework
Manage lifecycle of java classes(beans)
Boiler plate configuration(programmer
writes a lot of code to do minimal task)
Takes time to have a spring application
up and running
Benefits of Spring Boot
Dependency Resolution
Minimum Configuration
Embedded server for testing
Bean auto scan
Health metrics
Standarization for microservices
Cloud support
Adapt and support for 3rd party libraries
Examples:
A Spring bean is to be created only if a certain
dependency is available on the classpath. Use
@ConditionalOnClass and supply a class contained in
the dependency in question.
A Spring bean is to be created only if there is no bean
of a certain type or with a certain name created. Use
There are a number of condition annotations in
Spring Boot each of which can be used to control the
creation of Spring beans. The following is a list of the
condition annotations in Spring Boot (there are more):
Spring Boot will do the following when you
create the application
Classpath Scan
Default configuration setup
Create an appropriate ApplicationContext
instance
Start embedded application server(for web
application)
Starter POM
META-INF/spring.factories 1.Enable
Disable
Based on @Conditional and @Configuration it
@SpringBootApplication
This is a combination of
@SpringBootConfiguration,@EnableAutoConfi
guration and @ComponentScan
@SpringBootConfiguration
Indicates that a class provides Spring Boot
application @Configuration. Can be used as an
alternative to the Spring’s standard
@Configuration annotation so that
configuration can be found automatically
@EnableAutoConfiguration
This enables the component at runtime.
Spring Boot auto-configuration attempts to
automatically configure your spring application
based on their jar dependencies that you have
For example, in general in Spring MVC, DispatcherServlet and
InternalResourceViewResolver will be configured in web.xml or
we will go with Java Based configuration.
In Spring Boot, DispatcherServlet and
InternalResourceViewResolver are autoconfigured to avoid boiler
plate configuration.
@ComponentScan
This will be used by Spring IOC container to scan the packages
for fetching the bean.