-
Notifications
You must be signed in to change notification settings - Fork 40.2k
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
Allow application properties to be contributed from module jars #24688
Comments
Ordering will be tricky with this one. If two jars happen to provide |
Would using an |
We should look into the use-case behind #25033 when we fix this one. |
@philwebb & @wilkinsona ,thanks for your great work!
the dependency jar's configs just to reduce the duplicate or mistake works by the the project who use it. |
This comment has been minimized.
This comment has been minimized.
We should also consider #25084 when looking at this. |
I was mulling something along the lines of #25084 like making Maybe all becomes absurd at some point and ordering/precedence remains difficult but for most of our cases anyway you wouldn't expect collisions/conflicts since the libraries own their own vertical pieces. Perhaps end of the day what you need is not much easier than putting in an |
The characteristics of spring-boot-cloud-based project are as follows:
Many distributed development teams are obsessed with configurations they are not familiar with. In fact, they don't need to care about these configurations. They only need default values and full control. I've been thinking about this for a long time. It's a matter of architecture and foundation. In some interviews, their team needs a lot of people to develop, maintain and synchronize their configuration, which is not needed. I read the spring boot source code, do a lot of experiments, at last find the best solution I think, my changes #25082, #25080 impact point is the smallest. Fully compatible with your concerns. |
My main use case is splitting configuration properties into multiple files to avoid having a giant In Sprig Boot 2.3 I somewhat overcome this problem with something like this: @PropertySource(
ignoreResourceNotFound = true,
value = { "classpath:config/authentication.properties",
"classpath:config/authentication-${spring.profiles.active}.properties",
"classpath:config/persistence.properties",
"classpath:config/persistence-${spring.profiles.active}.properties" }) that is, since Now with Spring Boot 2.4 I can probably do something like this directly with What about something like this: spring.config.units=authentication,persistence which does something like this:
Just my 2 cents. |
How about adding an attribute to the |
We already have support for configuring a property's defaults by initialising the field's value or using We had a |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
See #27000 for another example of someone wanting to contribute config. |
#27544 is another one to consider when looking at this. |
could it be possible to allow merging default properties instead of replacing them? Adding a new method to allow add instead of replace? After that, something like defining some known property files in the jars could contribute to configure defaults. At the moment I am doing something like: public class MyEnvironmentPostProcessor implements EnvironmentPostProcessor {
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) {
try {
environment.getPropertySources().addLast(
new ResourcePropertySource("management-defaults",
"/somepath/management.properties"));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
} |
can i somehow weaken the priority of a profile @wilkinsona ? I want to include properties of my application-customprofile.yml but only if they are not defined in my application.yml Edit: That seems to work Application library:
customize:
url:
firstUrl: "https://app-overriding-url.com" Library: library:
url:
firstUrl: '${library.customize.url.firstUrl:https://librarys-own-url.com}' or Library fancy: library:
defaults:
url:
firstUrl: "https://librarys-own-url.com"
url:
firstUrl: '${library.customize.url.firstUrl:${library.defaults.url.firstUrl}} might help someone 😄 |
Currently
application.properties
andapplication.yaml
files are loaded from the classpath and the first match wins. This makes it hard to bundle common properties into jar files. It would be nice if we could find a way for jars to also contribute properties without needing to implement aEnvironmentPostProcessor
.There are a few things we need to be careful of:
spring.config.import=classpath:
The text was updated successfully, but these errors were encountered: