Auto-configuration
21 questions in 6 subtopics.
How auto-configuration works
What does 'auto-configuration backs off' mean? Give an example withObjectMapper or DataSource.Explain how @SpringBootApplication leads to a DataSource bean being created when you add spring-boot-starter-jdbc and a database driver.Why does Boot filter auto-configuration candidates by class presence before loading them, and how is this done without loading every class?Spring Boot made convention over configuration the standard for Java services. Why did it win over explicit configuration, and what long-term costs does it bring to large organisations?AutoConfiguration.imports
What is theAutoConfiguration.imports file, where is it located, and what replaced it compared with Boot 2.6 and earlier?After upgrading a shared library to Boot 3, its auto-configuration is silently ignored in all consuming services. The library still has META-INF/spring.factories with an EnableAutoConfiguration entry. Explain and fix it.Your platform ships internal auto-configurations in a shared jar used by 150 services. How would you order them relative to Spring Boot's own auto-configurations and to each other, and how would you keep that ordering safe across Boot upgrades?Conditional annotations
Read this:@Bean
@ConditionalOnProperty(prefix = "feature.audit", name = "enabled", havingValue = "true", matchIfMissing = false)
AuditService audit() { ... }
@ConditionalOnClass, @ConditionalOnMissingBean, @ConditionalOnWebApplication and @ConditionalOnExpression. Which would you avoid in a library and why?A custom auto-configuration uses @ConditionalOnBean(DataSource.class) but the bean is never created even though the application has a DataSource. What is the likely cause?Looking at conditional configuration over many years, where have you seen @Conditional-based designs create long-term risk in large estates, and what rules would you set so that conditional behaviour stays predictable?Condition evaluation report
Your application starts but noRedisTemplate bean exists even though you think Redis is configured. How do you find out why?A service on Boot 3 starts with 450 auto-configuration candidates and takes 25 seconds. Using the condition evaluation report, how would you trim what is configured?Incidents show that services behave differently in production because an auto-configuration silently activated or backed off after a dependency change. What fleet-wide practice would you introduce to catch this before deploy?Overriding and excluding auto-configuration
Show two ways to disableDataSourceAutoConfiguration in a Spring Boot application.A developer defines a custom ObjectMapper bean to add one module, and other teams report that spring.jackson.* properties stopped working and JSON dates changed format. What would you advise in the code review?Boot 4 modularises its auto-configuration into smaller technology-specific modules. As an architect for a large estate, how would you plan for such structural changes in a framework you depend on?Writing a custom starter
Design an internal starter that configures an audit client for all services. Describe the modules, the auto-configuration class, properties and how you would test it.Should an internal platform starter enforce security and logging settings that teams cannot override, or only provide defaults? How would you decide?Your platform team maintains 15 internal starters used by 200 services. Teams complain about surprises after upgrades. What governance would you put around internal starters?A platform group proposes replacing Spring Boot auto-configuration with an in-house framework of explicit wiring to remove 'magic'. How would you evaluate this build-versus-adopt decision over a five to ten year horizon?No question matches these choices.