Spring Profiles are a feature that allows different configurations and beans to be loaded for different environments such as Development, Testing, and Production. They help manage environment-specific settings without changing the application code.
A development environment may use an in-memory database, while a production environment uses a MySQL or PostgreSQL database. Spring Profiles allow the appropriate configuration to be loaded automatically.
@Configuration
@Profile("dev")
public class DevConfig {
}
@Configuration
@Profile("prod")
public class ProdConfig {
}
application.properties
spring.profiles.active=devA concise interview answer is
Spring Profiles are used to manage environment-specific configurations. By using the @Profile annotation, we can define different beans and settings for environments such as development, testing, and production, and Spring loads only the configuration associated with the active profile.
Last updated: 16 July 2026
Previous question: How does the prototype scope work in Spring?
Next question: What is Spring WebFlux and how is it different from Spring MVC?