Profiles: @Profile, Activation, Groups, Expressions and Environment-Specific Beans
Learn Profiles: @Profile, Activation, Groups, Expressions and Environment-Specific Beans (Phase 13 · Spring Profiles and Properties (Core), Spring Core) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Profiles • A profile is a named set of beans/configuration active only in some environments. @Profile("dev") on a @Component / @Configuration / @Bean ; expressions @Profile("!prod") , @Profile("dev | local") , @Profile("cloud & !k8s") (use parentheses to mix operators). Beans with no profile are always created. Default profile : default (active when none set; change with spring.profiles.default ). • Activation : spring.profiles.active=dev,metrics (property/env SPRING_PROFILES_ACTIVE /CLI --spring.profiles.active /JVM -D ), SpringApplication.setAdditionalProfiles , environment.setActiveProfiles...