Spring Boot

Spring Boot Auto-Configuration

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

20 pertanyaan wawancara·
Junior
1

What is auto-configuration in Spring Boot?

Jawaban

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?

Jawaban

@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?

Jawaban

@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 pertanyaan wawancara

Kuasai Spring Boot untuk wawancara berikutnya

Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.

Mulai gratis