Spring Boot

Spring Boot Auto-Configuration

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

20 câu hỏi phỏng vấn·
Junior
1

What is auto-configuration in Spring Boot?

Câu trả lời

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?

Câu trả lời

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

Câu trả lời

@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 câu hỏi phỏng vấn

Nắm vững Spring Boot cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí