-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Importing config files across modules #26120
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
Comments
@edudar Can you please provide a minimal sample that reproduces the behaviour that you have described? |
Published to edudar/sb26210 Right now,
If you uncomment
|
Thanks very much for the sample. The multi-module aspect doesn't appear to be important here - I can also reproduce the issue with all four properties files in the same module. The key is to have the imports for |
@scottfrederick shouldn't |
As stated in the documentation, profile-specific properties files override non-profile-specific properties files and properties from imported files override properties from the file that contains the import. Without the
With the |
I think there are two different views here. (2.1) I do understand where the doc is coming from. If I have an external config like a configtree or consul or similar deployed in production/staging/uat/younameit, I do want values from there to override my bundled properties from a jar. Essentially, jar provides some predefined properties that can be overridden in production. (2.2) But the example in this ticket is pretty much the opposite. That's why I named files When I run my app in dev, I will get 500ms timeouts as it's set in config, because |
As you said initially, there are a few issues here. One is a bug that's causing a confusing error message unrelated to modules and precedence of property loading. I've now split that out into #26147 so we can address that bug. The rest of this discussion has to do with a specific problem you are trying to solve and whether your approach will work given the design of Spring Boot's property loading. Let's continue that discussion here. |
Breaking down the the comment above:
This is the expected behavior, as stated in the documentation (the values from the imported file will take precedence over the file that triggered its import).
This is a side-effect of the fact that a file like
This is the part that is contrary to the explicit design of the |
Also see #24688 for a similar use case. |
Yeah, that's an ultimate question in the late discussion here. I'll close this one then as there are two tickets that cover it now. |
Uh oh!
There was an error while loading. Please reload this page.
I have two modules in the same project, one by another:
Been using custom
EnvironmentPostProcessor
to loadbase-
config intoA
but with SB 2.4 I wanted to giveconfig.import
a try. But there are a few issues arisen.(1)
In
A/application.yaml
I've added the following:In
A/application-dev.yaml
it's respectively:Trying to start
A
fails withConfig data location 'classpath:/base-application-dev.yaml' does not exist
. That's rather confusing considering that it does exist indeed and thatclasspath:/base-application.yaml
is loaded just fine from the same location. To verify that, I made a typo in the file name and it failed for'classpath:/bas-application.yaml'
as expected.Renaming
base-application-dev.yaml
to something profile-unrelated likesome-file.yaml
still fails with resource does not exist.(2)
If I don't change
A/application-dev.yaml
at all, I do see that SB takesB/base-application-dev.yaml
into account when loadingclasspath:/base-application.yaml
and properly loads it. The application starts just fine with all properties. So clearly it does exist in (1). But now the ordering of property sources is not correct. Here's what it is fromenvironment
:base-dev
overridesdev
butapplication
overridesbase-application
.The text was updated successfully, but these errors were encountered: