Spring Boot

Spring Boot Auto-Configuration

Spring Boot auto-configuration, @SpringBootApplication, starters, conditional beans, spring.factories

20 Interview-Fragen·
Junior
1

What is auto-configuration in Spring Boot?

Antwort

Auto-configuration automatically configures Spring beans based on dependencies present in the classpath. For example, if spring-boot-starter-data-jpa is present, Spring Boot automatically configures a DataSource, EntityManagerFactory, and TransactionManager. This significantly reduces the manual configuration required.

2

Which annotation enables auto-configuration in Spring Boot?

Antwort

@EnableAutoConfiguration enables the Spring Boot auto-configuration mechanism. This annotation is included in @SpringBootApplication which combines @Configuration, @EnableAutoConfiguration, and @ComponentScan. It scans the classpath to detect auto-configuration classes.

3

What does the @SpringBootApplication annotation combine?

Antwort

@SpringBootApplication is a composite annotation that combines three essential annotations: @Configuration (declares a configuration class), @EnableAutoConfiguration (enables auto-configuration), and @ComponentScan (scans components in current package). This avoids declaring these three annotations separately.

4

How to exclude a specific auto-configuration?

5

What is the purpose of @ConditionalOnClass?

+17 Interview-Fragen

Meistere Spring Boot für dein nächstes Interview

Zugang zu allen Fragen, Flashcards, technischen Tests, Code-Review-Übungen und Interview-Simulatoren.

Kostenlos starten