Profiles & Environment
Spring profiles (@Profile), application-{profile}.properties, profile activation, environment variables
1What does the @Profile annotation allow in Spring?
What does the @Profile annotation allow in Spring?
Respuesta
The @Profile annotation allows conditional bean or configuration activation based on active profiles. When a profile is active (via spring.profiles.active), only beans annotated with that profile are loaded into the Spring context. This enables different configurations for dev, test and production without code duplication. For example, using H2 database in dev and PostgreSQL in production.
2Which property activates a Spring Boot profile at application startup?
Which property activates a Spring Boot profile at application startup?
Respuesta
The spring.profiles.active property activates one or more profiles at startup. It can be defined in application.yml, via command line (--spring.profiles.active=prod), or through environment variables. This property is the standard method for selecting the execution environment (dev, test, prod).
3How to name a configuration file specific to the 'production' profile?
How to name a configuration file specific to the 'production' profile?
Respuesta
Profile-specific configuration files follow the pattern application-{profile}.yml or application-{profile}.properties. For the 'production' profile, the file will be application-production.yml. These files override properties from the main application.yml when the corresponding profile is active.
What is the difference between spring.profiles.active and spring.profiles.include?
What is the Environment interface in Spring?
+17 preguntas de entrevista
Otros temas de entrevista Spring Boot
Spring Core - IoC & DI
Spring Boot Auto-Configuration
Spring Boot Starters
Application Properties & YAML
Logging with SLF4J & Logback
Spring Boot DevTools
Spring MVC Basics
Spring REST Controllers
Request & Response Handling
Exception Handling
Bean Validation
Spring Data JPA Basics
JPA Entities & Relationships
JPA Queries
Spring Data Repositories
Spring Security Basics
Spring Boot Actuator
Unit Testing with JUnit & Mockito
Spring Boot Testing
RestTemplate & WebClient
Async & Scheduling
Caching with Spring
Spring WebFlux (Reactive)
Spring Transactions
Advanced Authentication & Authorization
JWT & Stateless Security
OAuth2 & Authorization Server
Spring Boot & Docker
Microservices with Spring
Spring Cloud Config
Performance Optimization
GraalVM Native Images
Domina Spring Boot para tu próxima entrevista
Accede a todas las preguntas, flashcards, tests técnicos, ejercicios de code review y simuladores de entrevista.
Empieza gratis