Refine message.properties detection
Currently ResourceBundleCondition causes a full scan of every jar file, if we change the pattern to messages.properties rather than messages-*.properties it won't. Should make things faster at the expense of needing that file (even if empty).
Or we could look at dropping the condition all together.
I could be missing something, but this change doesn't seem to be documented in the Spring Boot Reference Document. Is messages.properties really required when using messages_
Also, does this change not break backward compatibility?
Here's my scenario: I've messages_en.properties and messages_fr.properties files in the classpath, but no messages.properties file. This works fine with Spring Boot v1.3.0.
When I upgrade to v1.3.2, because of the lack of messages.properties file, MessageSourceAutoConfiguration is not creating a MessageResource bean on startup so AbstractApplicationContext.initMessageSource() will create a DelegatingMessageSource with parentMessageSource=null and later on the application throws this exception:
org.springframework.context.NoSuchMessageException: No message found under code 'msg-1' for locale 'en'.
at org.springframework.context.support.DelegatingMessageSource.getMessage(DelegatingMessageSource.java:69) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
@davidkiss The documentation was never particularly clear on this in the first place so there wasn't anything to change there. I did add a note on the release blog about the change.
I'm afraid that the change really needs to stay so that a full jar scan is not required for every application.
@philwebb, recently I updated a project from 1.3.1 to 1.4.1, and it failed to translate errors because this change. So I refactored the name of the messages file from messages_es.properties to messages.properties and worked again, but we are going to add support to more languages to this API soon.
What is the proper why to add more languages to a Spring Boot application after this change?
@mrsarm messages.properties is simply used as a fallback when you don't have a specific file for the requested locale. As such, it's recommend that you always have one and its contents should be in whatever language seems most appropriate for use as a fallback. You should then continue to have files such as messages_es.properties that contain locale-specific messages.