Table of Contents
What is Spring Boot?
Spring Boot is a set of preconfigured framework that works on top of Spring Framework and simplifies configuring a Spring application.
What are the advantages of using Spring Boot?
Most important advantage is easy configuration of Spring application.
Additional to this it provides something more:
- Integrated web containers that allow for easy testing
- Starters – sets of dependencies that help setting up a “typical” application
- Little or no configuration
- Decrease amount of boilerplate code
Why is it “opinionated”?
It makes assumptions on what you need based on dependencies from the classpath.
How does it work? How does it know what to configure?
It scans dependencies from classpath and adds support for different components by initializing “maybe” required beans. For example if it sees a dependency on Thymeleaf, 3 beans that Thymeleaf uses are automatically initialized:
- ThymeleafViewResolver
- SpringTemplateEngine
- TemplateResolver
Moreover it also scans the templates directory from resources for Thymeleaf templates.
What things affect what Spring Boot sets up?
Starters that are added to dependencies – only if @EnableAutoConfiguration or @SpringBoot application are used.
How are properties defined? Where?
Properties are usually defined in application.properties or application.yml
Would you recognize common Spring Boot annotations and configuration properties if you saw them in the exam?
Spring Boot annotations include:
- @SpringBootAnnotation – is sum of 3 annotation: @Configuration, @EnableAutoConfiguration, @ComponentScan
- @EnableAutoConfiguration
Configuration can be differentiated by the filename where they are placed.
What is the difference between an embedded container and a WAR?
Embedded container is a server that comes with the resulting application whereas WAR is an archive that can be deployed on an external container.
What embedded containers does Spring Boot support?
- TomCat
- Jetty
- Undertow
What does @EnableAutoConfiguration do? What about @SpringBootApplication?
@EnableAutoConfiguration – turns on Spring Boot autoconfiguration
@SpringBootApplication does 3 things:
- turns on autoconfig
- enables auto-scanning
- defines a configuration class
What is a Spring Boot starter POM? Why is it useful?
Starter POM is a set of dependencies that work as some templates for dependencies used for different tasks.
Spring Boot supports both Java properties and YAML files. Would you recognize and understand them if you saw them?
Java properties files come in application.properties file; YAML come in application.yml
Can you control logging with Spring Boot? How?
Yes. First you add the required dependencies to the classpath and then configure the required framework using application.properties or framework-specific configuration file placed in the classpath.