-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
MessageSourceAutoConfiguration fails to read messages.properties when running an executable jar with name starting with "spring-boot-" #4811
Comments
A possible workaround for this is to set |
This is a workaround for spring-projects/spring-boot#4811 which causes MessageSourceAutoConfiguration to fail to read message.properties when running an executable jar.
I am not sure, the current situation looks quite wrong to me. Here are my thoughts on your proposals:
I guess the wildcard scanning is the problem in the first place. Maybe we can change that or we could bring a configuration option that would whitelist a given name ( I am afraid we'll have to give it more thoughts as fixing this one does not look straightforward to me. |
Option 2 might become a maintenance nightmare. One has to remember to extend the
Good point, didn't think about that.
Yes, and the list might become long if you happen to use several project with the spring-boot prefix (or any other prefix listed in the
Fine by me. The workaround I described above, works for me. Thank you for looking into this on short notice. |
My vote would be a variation on 2) and switch |
Maybe we could try to fix that instead (moving the location or how it is discovered). |
See #4930 |
Update `ResourceBundleCondition` to only enable the messages source if `messages.properties` (and not `messages*.properties`) exists. This operation is much faster that performing a pattern match since a full jar entry scan is not required. Since adding `messages.properties` is good practice and this change allows us to delete the custom `PathMatchingResourcePatternResolver` it seems like a fine compromise to make. Fixes gh-4930 See gh-4811
We've decided to change the |
Nice, thanks! |
When MessageSourceAutoConfiguration looks for messages.properties it tries to load all classpath resources using
MessageSourceAutoConfiguration$SkipPatternPathMatchingResourcePatternResolver.doFindAllClassPathResources(String)
. In my case I'm working on an application called spring-boot-heroku-demo, so it will also filter the root classpath resourceURL [jar:file:/Users/bene/workspace/projects/spring-boot-heroku-demo/target/spring-boot-heroku-demo-0.0.1-SNAPSHOT.jar!/]
because file name returned by that resource is "spring-boot-heroku-demo-0.0.1-SNAPSHOT.jar!/" which starts with "spring-boot".It works when running the application from an IDE for example, because in this case resources will be loaded from the file system and not from the jar, so a completely different code path is taken to find the messages.properties file.
Possible solutions:
SKIPPED
array inMessageSourceAutoConfiguration$SkipPatternPathMatchingResourcePatternResolver
I'm happy to contribute a patch. Please let me know which solution you'd like to use.
The text was updated successfully, but these errors were encountered: