in springboot 2.7.15 try to run java -jar --spring.profiles.active=prod , accpect only one prod, but found two active profile dev and prod.in springboot 2.7.10 is ok, only one is active?
Comment From: wilkinsona
There's nothing in Boot itself that will enable a dev profile automatically so something in your app or one of its dependencies must be doing so. Without knowing what's activating the dev profile there's no way of knowing why it's happening with 2.7.15 but not with 2.7.10.
If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: jinyulei0710
with more debug,i found that PropertySourceBootstrapConfiguration the behavior may changed, it load the bootstrap.yaml again and than the dev profile was add again.
Comment From: jinyulei0710
private void handleProfiles(ConfigurableEnvironment environment) {
if (bootstrapProperties.isInitializeOnContextRefresh() && !environment.getPropertySources()
.contains(BootstrapApplicationListener.BOOTSTRAP_PROPERTY_SOURCE_NAME)) {
// In the case that spring.cloud.config.initialize-on-context-refresh is true
// this method will
// be called during the bootstrap phase and the main application startup. We
// only manipulate the environment profiles in the bootstrap phase as we are
// fetching
// any additional profile specific configuration when this method would be
// called during the
// main application startup, and it is not valid to activate profiles in
// profile specific
// configuration properties, so we should not run this method then.
return;
}
Set<String> includeProfiles = new TreeSet<>();
List<String> activeProfiles = new ArrayList<>();
for (PropertySource<?> propertySource : environment.getPropertySources()) {
addIncludedProfilesTo(includeProfiles, propertySource, environment);
addActiveProfilesTo(activeProfiles, propertySource, environment);
}
// If it's already accepted we assume the order was set intentionally
includeProfiles.removeAll(activeProfiles);
// Prepend each added profile (last wins in a property key clash)
for (String profile : includeProfiles) {
activeProfiles.add(0, profile);
}
List<String> activeProfilesFromEnvironment = Arrays.stream(environment.getActiveProfiles())
.collect(Collectors.toList());
if (!activeProfiles.containsAll(activeProfilesFromEnvironment)) {
activeProfiles.addAll(activeProfilesFromEnvironment);
}
environment.setActiveProfiles(activeProfiles.toArray(new String[activeProfiles.size()]));
}
Comment From: jinyulei0710
@wilkinsona is the behavior changed in bootstrap or I should make a issue in spring cloud project?
Comment From: wilkinsona
The bootstrap config is a Spring Cloud feature. Please open an issue there if you believe you have found a bug.