Sorry if this turns out to be a question Andy, seems like a feature
I'd like to be able to have spring search for a profile specific file, by searching upwards, like git will for .gitignore.
Something like file:optional-parent:application-${profile}.properties
this would be useful for things like monorepo support and developer secure credential configuration that works for all clients (cli, IDE, etc). We actually have a multi monorepo situation (libraries and apps)
current workaround
@SpringBootApplication
@EnableConfigurationProperties
@ConfigurationPropertiesScan
@PropertySource("file:\${HOME}/.e1-application.properties")
open class TestApplication
@Suppress("SpreadOperator")
fun main(args: Array<String>) {
runApplication<TestApplication>(*args)
}
If this is already possible without writing more code, and without customizing any clients like the IDE, can you please put it in the documentation
Comment From: philwebb
We don't currently support searching upwards for files. If we wanted to add support we'd probably need to change StandardConfigDataLocationResolver and I think we'd want to make it opt-in rather than a default.
If you want to do this currently, you might be able to use relative import. E.g. in the client app you'd have application.properties with the following:
spring.config.import=../application.properties
That would pick up a shared application.properties (and all profile specific variants) from the parent directory which could contain all the credential properties.
Comment From: xenoterracide
When I tried to do that I didn't seem to be able to figure out the depth. It seemed like perhaps it wasn't consistently using the same directory between IntelliJ and just running as Gradle normally. In fact I'm not sure the depth would be consistent between tests. This is why I think recursive searching would be a better solution, as I did actually try this.
Comment From: philwebb
We're cleaning out the issue tracker and closing issues that we've not seen much demand to fix. Feel free to comment with additional justifications if you feel that this one should not have been closed.
Comment From: xenoterracide
this is an alternative solution to #39156