Configuration, environment and profiles
24 questions in 6 subtopics.
@Value
What is the difference between ${...} and #{...} in a Spring@Value annotation? Give examples with default values.A @Value field is null at runtime. List the common causes.When would you use @ConfigurationProperties instead of @Value, and why?Environment and PropertySources
What is the Spring Environment, and in what order does Spring Boot resolve a property defined in several places?How would you add a customPropertySource, for example values read from an internal secrets service, before the application context is created?An environment variable APP_FEATURE_ENABLED=true does not override app.feature-enabled=false from application.yml in production. How would you investigate?Design how configuration should be managed for 100 services across development, staging and production.Configuration errors cause a large share of your production incidents. What long-term strategy would you set for configuration management across the company?Profiles
How do Spring profiles work, and how do you activate them in Spring Boot?In a singleapplication.yml, how do you set a property only when the 'prod' profile is active?A codebase has profiles dev, test, qa, staging, prod, prod-eu, prod-us and local-docker, and nobody knows which beans are active where. How would you simplify it?Over a decade, many organisations have moved from environment-specific builds and profiles to externalised configuration and feature flags. Explain why, and what governance you would set today.@Conditional
What does the@Conditional annotation do, and name four common Spring Boot conditions.Why does the Spring Boot documentation say @ConditionalOnBean and @ConditionalOnMissingBean are reliable only in auto-configuration classes?An auto-configured bean you expected is missing, or your own bean is ignored. How do you find out which conditions matched?You are writing an internal Spring Boot starter for your company's messaging client. How would you use conditions so it works safely across many services?Your internal starters have grown to hundreds of conditions, and nobody can predict which beans a service gets. How would you bring this under control over the next few years?SpEL
Write SpEL expressions that (1) call a static method, (2) reference another bean's property, and (3) use a safe navigation and default value.Where does Spring use SpEL besides@Value, and what problems does putting logic in SpEL cause?A security review finds that your application evaluates SpEL expressions built from request parameters for dynamic filtering. What is the risk and how do you fix it?@Import and configuration composition
What does@Import do, and what kinds of classes can it import?How does Spring Boot find and load auto-configurations, and how does DeferredImportSelector fit in?How would you structure configuration in a large modular monolith so that each module owns its beans and the application composes them explicitly?Spring configuration moved from XML to Java configuration to Boot auto-configuration. What are the long-term costs of auto-configuration for a large organisation, and how do you manage them?No question matches these choices.