Spring Boot

Spring Boot Auto-Configuration

Spring Boot auto-configuratie, @SpringBootApplication, starters, conditionele beans, spring.factories

20 gespreksvragen·
Junior
1

Wat is auto-configuratie in Spring Boot?

Antwoord

Auto-configuratie configureert Spring-beans automatisch op basis van de afhankelijkheden die in de classpath aanwezig zijn. Als bijvoorbeeld spring-boot-starter-data-jpa aanwezig is, configureert Spring Boot automatisch een DataSource, een EntityManagerFactory en een TransactionManager. Dit vermindert de benodigde handmatige configuratie aanzienlijk.

2

Welke annotatie schakelt auto-configuratie in Spring Boot in?

Antwoord

@EnableAutoConfiguration schakelt het auto-configuratiemechanisme van Spring Boot in. Deze annotatie is opgenomen in @SpringBootApplication, die @Configuration, @EnableAutoConfiguration en @ComponentScan combineert. Ze scant de classpath om auto-configuratieklassen te detecteren.

3

Wat combineert de annotatie @SpringBootApplication?

Antwoord

@SpringBootApplication is een samengestelde annotatie die drie essentiële annotaties combineert: @Configuration (declareert een configuratieklasse), @EnableAutoConfiguration (schakelt auto-configuratie in) en @ComponentScan (scant componenten in het huidige package). Hierdoor hoeven deze drie annotaties niet afzonderlijk te worden gedeclareerd.

4

Hoe sluit je een specifieke auto-configuratie uit?

5

Wat is het doel van @ConditionalOnClass?

+17 gespreksvragen

Beheers Spring Boot voor je volgende gesprek

Krijg toegang tot alle vragen, flashcards, technische tests, code review-oefeningen en gespreksimulatoren.

Begin gratis