Spring_Boot_Interview_Problems
Spring_Boot_Interview_Problems
How does Spring Boot auto-configuration work and how can it be customized?
Spring Boot uses @EnableAutoConfiguration and @SpringBootApplication to configure
beans automatically.
Auto-configuration classes are loaded using SpringFactoriesLoader from
spring.factories.
Customization options:
Override specific beans by declaring them explicitly.
Use @ConditionalOn... annotations to control auto-configuration behavior.
Disable auto-config classes via @EnableAutoConfiguration(exclude = ...).
Auto-config is context-aware and conditional based on classpath, properties, and bean
presence.
How do Spring Boot profiles work and how can they be used for environment-
specific configuration?
Spring profiles allow grouping of beans and properties for different environments (e.g.,
dev, test, prod).
Activation:
Set via application.properties (spring.profiles.active=dev), environment variable, or
command-line args.
Use @Profile annotation on beans or configurations.
Support for profile-specific property files:
application-dev.properties, application-prod.yml, etc.
Profiles help isolate environment concerns and avoid hardcoded differences.