Spring Boot

Spring Boot Auto-Configuration

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

20 면접 질문·
Junior
1

What is auto-configuration in Spring Boot?

답변

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?

답변

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

답변

@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 면접 질문

다음 면접을 위해 Spring Boot을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기