Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Why Use Spring Boot?

Java | Spring Boot | AWS Developer’s Network


Why Use Spring Boot?

N
owadays, Spring Boot is the obvious choice for developing state-of -art,
production ready web applications specific to spring. It’s website
(https://spring.io/projects/spring-boot) also states its real advantages.
Spring Boot is an amazing Spring tool created by Pivotal with the title Improved
support for ‘Containerless’ web application.

Current release of
Spring Boot
Version is “3.1”

Java | Spring Boot | AWS Developer’s Network


Why Use Spring Boot?

Java | Spring Boot | AWS Developer’s Network


Why Use Spring Boot?
You must be Wondering:

W
hy Container-less? Because today’s cloud environment, or PaaS, provide most of the
features offered by container-based web architectures, such as Reliability, Management,
or Scaling. Therefore, Spring Boot focuses on making itself an Ultra-light Container.

Java | Spring Boot | AWS Developer’s Network


Why Use Spring Boot?

D
eveloper view of Spring
Boot. It sandwiches itself
between the developer
and the Spring Framework.
Spring Boot Several “Spring Framework
components are automatically
configures by Spring Boot” based
Spring Framework on the Spring components a
Spring Ecosystem developer uses.

Java | Spring Boot | AWS Developer’s Network


How Does Spring Boot Works?

Java | Spring Boot | AWS Developer’s Network


How Does Spring Boot Works?

@SpringBootConfiguration: Designates this class a configuration class. Although there’s not


much configuration in the class yet, You can add Java Based Spring Framework Configuration to
this call if you need to. This Annotation is, in fact, a specialised from the @Configuration
Annotation.
Java | Spring Boot | AWS Developer’s Network
How Does Spring Boot Works?

public static void main( … ) Starts Java and then the application

@SpringBootApplication A convenience annotation that wraps commonly


used annotations with Spring Boot

@Configuration Spring configuration on startup


@EnableAutoConfiguration Auto configures frameworks
@ComponentScan Scans project for Spring components

SpringApplication.run( … ); Starts Spring, creates spring context, applies


annotations and sets up container

Java | Spring Boot | AWS Developer’s Network


How Does Spring Boot Works?

package com.example.demo; Intelligent and seemingly


@EnableAutoConfiguration “magical” annotation that
public class DemoApplication {
enables Features &
public static void main(String[] args){
... configures
}
} Spring Boot Functionality

Java | Spring Boot | AWS Developer’s Network


How Does Spring Boot Works?
3 Common annotation in Spring Boot
package com.example.demo;
➢ @Configuration
@Configuration
• Marks a configuration file
@ComponentScan • Java equivalent of <beans> file (replacement for XML)
@EnableAutoConfiguration
public class DemoApplication { ➢ @ComponentScan
• Looks for @Components (Spring Beans)
public static void • Automatically Discovers & Register them as
main(String[] args) { Components [@Component, @Controller, @Service]
...
} ➢ @EnableAutoConfiguration
} • Master Runtime switch for Spring Boot
• It Tell’s the Spring Boot to Automatically Configure
any Components [i.e, DispatcherServlet, Datasource
etc.]
• Examines Application context
• Creates missing beans based on intelligent defaults

Java | Spring Boot | AWS Developer’s Network


How Does Spring Boot Works?
package com.example.demo;

@SpringBootApplication
public class DemoApplication {

public static void main(String[] args) {


...
}
}

@SpringBootApplication = @Configuration + @ComponentScan + @EnableAutoConfiguration

Introduced in Spring Boot 1.2.x Version onwards Three annotation is reduced to One
Annotation @SpringBootApplication

Java | Spring Boot | AWS Developer’s Network


Thank You!
LinkedIn Java Group
https://lnkd.in/grxYWYnq
Java | Spring Boot | AWS Developer’s Network

You might also like