Spring Boot FAQ: Top Questions
19. How do profiles work in Spring Boot?
Spring Boot allows multiple configurations for different environments using the concept of profiles. You can define environment-specific properties using application-{profile}.properties
.
🗺️ Steps:
- Create profile-specific files (e.g.,
application-dev.properties
). - Activate profile via
spring.profiles.active=dev
.
🏆 Expected Output:
Loads settings from dev configuration during startup.
🛠️ Use Cases:
- Separation of dev, test, and prod configs.
- Switching environments via command line or environment variables.