-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Document when a spring.config.import value is relative and when it is fixed #45349
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
In the interests of avoiding duplicated effort, I'm going to close this one for now in favor of the question on Stack Overflow. We can re-open it if the Q&A determines that a change to Spring Boot's code or documentation is needed. |
@wilkinsona wrote:
Yep, fair enough. I'll gratefully accept tips on what I should have done to improve my chances of a timely resolution (feature or bug?). After reading the guidelines in the comments of a new issue, I decided that the correct approach was to initially characterize the issue as a question on Stack Overflow. Should I simply have been more patient, waited longer for an answer on Stack Overflow? For now, I'm going to document this current difference in behavior for my app users, to spare them the surprise that I experienced. |
Yes, I think so. 3 days isn't long for an unpaid "support" channel.
I think that's your best option, particularly given that you say you're on a tight schedule. Even if a change is to be made in Spring Boot, it would not be released until the end of this month at the earliest. From your recent comment on the Stack Overflow question, I note that you're using Spring Boot 3.1.12. Open source support for Spring Boot 3.1.x ended in June 2024 and commercial support ends in June 2025. To be eligible for open source support I'd recommend upgrading to at least Spring Boot 3.3.x and ideally 3.4.x. Alternatively, commercial support is available. |
Digging some more, I think we need to improve the documentation. The behavior that you have observed with 3.1.x remains in 3.3.x and later and is intended. When There are tests for this behavior but the documentation seems to be lacking. We can use this issue to make some improvements. |
@wilkinsona wrote:
👍 Thank you so much for that unequivocal statement; that's very helpful, exactly the kind of response I'd hoped for. I now feel better about documenting that behavior in my app's docs. |
Uh oh!
There was an error while loading. Please reload this page.
Several days ago on Stack Overflow I asked the related question, "spring.config.import: relative file path with vs without file: prefix?". I've had no answer.
I'm raising this issue here not as a question, but as either a docs enhancement request or a bug report, depending on whether the Spring Boot developers characterize the difference in behavior (details below) as a feature or a bug.
I'd planned to wait for answers on Stack Overflow and then, depending on those answers, possibly raise an issue here. However (acknowledging this is my problem), I'm on a tight schedule: I'm writing the user documentation for a Spring Boot application, and I want to know whether/how to document using
spring.config.import
to refer to a relative file path without afile:
prefix.Difference in behavior
I've recently been caught out by the difference that the
file:
prefix makes to a relative file path forspring.config.import
.In practice, it seems to be the case that:
file:
prefix, a relative file path is relative to the current working directoryfile:
prefix, a relative file path is relative to the file that containsspring.config.import
For example, given the following current working directory (that is, where
config
is a child directory of the current working directory):(In case anyone's wondering: yes, I'm familiar with profiles, and typically prefer them to
spring.config.import
.)In
application.yaml
, to importapplication-import.yaml
, I can specify either:or:
This issue: docs enhancement request or bug report
The nature of this issue depends on whether the Spring Boot developers characterize this difference in behavior as a feature (working by design) or a bug:
spring.config.import
for a relative file path with vs without thefile:
prefix.Related Spring Boot docs
I've looked for, but not found, information in the Spring Boot docs about specifying the location of a configuration properties file (such as
application-import.yaml
) as a relative path in the file system with afile:
prefix versus without afile:
prefix. If I've missed it, please point me to it.It occurred to me that the Spring Boot developers and docs writers might say, "In the context of
spring.config.*
properties, all references to file system paths should be explicitly prefixed byfile:
. We deliberately don't document the behavior without that prefix."But then, I found this counterexample in the 2020 Spring blog post "Config file processing in Spring Boot 2.4":
So, the Spring Boot developers have explicitly considered the behavior for locations without a prefix. But, there's no mention of the difference in behavior between specifying a relative file path with or without a
file:
prefix.Related Spring Framework docs
The "underlying" Spring Framework docs topic "Core Technologies / Resources" contains related information about specifying a file path with or without a
file:
prefix, but, understandably in that relatively low-level context, it's fairly general. For example:"appropriate to the specific application context" makes sense in the context of those relatively low-level Spring Framework docs, but it isn't much help to a user of the "higher-level" Spring Boot
spring.config.import
property.If this difference in behavior is a feature and not a bug, then, unless I'm missing something in the Spring Boot docs, I suggest that the Spring Boot docs description of
spring.config.import
ought to explicitly describe this particular "appropriate to the specific application context" behavior.The text was updated successfully, but these errors were encountered: