I believe that I am simply missing some part of the documentation.
Spring @Profile
says:
… If no profile is active using one of those options, a default profile
is enabled as a fallback. The name of the default profile is “default”
The simple example:
@Component
public class Config {
@Bean
void a() {
System.out.println("a - empty");
}
@Bean
@Profile("default")
void b() {
System.out.println("b - default");
}
@Bean
@Profile("dev")
void c() {
System.out.println("c - dev");
}
}
Run with empty profile:
No active profile set, falling back to 1 default profile: "default"
a - empty
b - default
Run with using a default
profile:
The following 1 profile is active: "default"
a - empty
b - default
Run with dev
profile:
The following 1 profile is active: "dev"
a - empty
c - dev
Could you explain to me why does it pick the “b” in the second case and does not in the 3rd?