-
Notifications
You must be signed in to change notification settings - Fork 41k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditional documents in profile specific file are not loaded consistently #11109
Comments
Sorry, I'm finding it a little hard to follow your description of the problem. Can you please provide a small sample that reproduces the problem so that we can be sure we're investigating the right thing? |
I'm sorry, my english isn't that good. Basically the problem is simple: application.properties: application-bar.yaml
Result: Does that help? lG |
@LProemer any specific reason you need to use |
The reason would be Feature-Configurations. The Feature is only enabled when the profile "bar" is set and should then configure it acording to the environment. |
I also ran into this problem and it took quite some time to track it down and figure out why it was happening. My use case is that we have configuration properties specific to logical environments (say Therefore, to achieve this, it seemed reasonable to me to put say the DEV environment ---
spring:
profiles: cloud,server
boot.admin.client.uri: http://my-admin-url The above works fine, actually, if the active profiles are in the "right" order ===================================================================
--- spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java (revision 3ae4a541b630fb7bccf45ebd0922c19d099c2276)
+++ spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java (date 1521006994000)
@@ -777,7 +777,7 @@
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = application.run(
- "--spring.profiles.active=activeprofilewithdifferentsubdoc,activeprofilewithdifferentsubdoc2");
+ "--spring.profiles.active=activeprofilewithdifferentsubdoc2,activeprofilewithdifferentsubdoc");
String property = this.context.getEnvironment().getProperty("foobar");
assertThat(property).isEqualTo("baz");
}
Lines 774 to 783 in 3ae4a54
I've also pushed a repro project with a failing test case: https://github.com/shakuzen/demo-compound-profile To summarize the use case, being able to use sub-documents in YAML files that are themselves profiled allows for AND semantics. In the example shown above, the For my specific use case mentioned above, we can work around this thanks to Spring Boot Admin client offering an |
This should be solved by config data rewrite in 2.4.x. For multi-document files, later documents can override the properties defined in earlier ones. With the following configuration in
the result is my.prop1 = dev |
I've following problem.
I've an instance with following active profiles:
dev, test, foo
and apllication-test.yaml file
My intuition would tell me:
my.prop1 = dev
my.prop2 = foo
Thought the result is really:
my.prop1 = default
my.prop2 = foo
It seems to use the order of profiles, rather then the order of the document.
This seems to be different then what the documentation is saying.
(Correct me if I'm wrong)
Further more my.prop3 seems to be not set at all as if this section is ignored even if dev is set active.
Is this a bug of Spring or is there a trick to it?
lG
Lukas
The text was updated successfully, but these errors were encountered: