Andrew Golovko
@andrewgolovko
Blog of a self-taught programmer writing about the experience, tips and other stuff
153 posts
Spring Boot

M04 Q23 What are the examples of @Conditional annotations? How are they used?

Spring Boot supports following Conditional Annotations for AutoConfiguration classes:

M04 Q22 How do you customize Spring auto configuration?

You can customize Spring Auto Configuration by creating your own autoconfiguration module with Auto Configuration Class.

M04 Q21 What is spring.factories file for?

spring.factories file, located in META-INF/spring.factories location on the classpath, is used by Auto Configuration mechanism to locate Auto Configuration Classes. Each module that provides Auto Configuration Class needs to have METAINF/spring.factories file with org.springframework.boot.autoconfigure.EnableAutoConfiguration entry that will point Auto Configuration Classes.

M04 Q20 How are DataSource and JdbcTemplate autoconfigured?

DataSource and JdbcTemplate are configured by Auto Configuration Classes defined in spring-boot-autoconfigure module.

M04 Q19 - Does Spring Boot do component scanning? Where does it look by default?

Yes, Spring Boot is performing component scan, because @SpringBootApplication annotation is enabling component scanning with usage of @ComponentScan annotation.

M04 Q18 What does @SpringBootApplication do?

@SpringBootApplication annotation is supposed to be used on top of the class and it was introduced for convenience. Usage of @SpringBootApplication annotation is equivalent to usage of following three annotations:

M04 Q17 What does @EnableAutoConfiguration do?

@EnableAutoConfiguration annotation turns on auto-configuration of Spring Context. Auto-configuration tries to guess Spring Beans that should be created for your application based on configured dependencies and configurations with @ConditionalOn... annotations.

M04 Q16 How does Spring Boot know what to configure?

Spring Boot knows what to configure by usage of Auto Configuration Classes defined in starter modules. Spring Boot searches for META-INF/spring.factories on classpath, whenever entry org.springframework.boot.autoconfigure.EnableAutoConfiguration is encountered in this file, Auto Configuration Class pointed by this property is loaded.

M04 Q15 What embedded containers does Spring Boot support?

Spring Boot supports following embedded containers:

M04 Q14 What is the difference between an embedded container and a WAR?

WAR (Web Application Archive) is a file that represents web module. WAR cannot be executed in standalone mode, it needs to be deployed to Application Server like Tomcat or WildFly.