In my project, I set custom messages directory like so:
spring.messages.basename=i18n.messages
This worked fine, until I updated to jdk11 and used module-info.java.
In this project I had to pass the custom i18n directory to fxml annotation which is part of a dependency jar, in order for it to load the properties files internally. This didn't work until I opened the resource derectory/package to that depndency in my module-info.jafa like so:
opens i18n to de.felixroske.jfxsupport;
If I don't open the package, the resource cannot be loaded. At another point in my code I try to load the bundle like so:
@Component
public class ApplicationMessages
{
@Autowired
MessageSource ms;
...
The problem is that spring boot autowires an empty bundle! I believe the same reason holds for spring boot like in the dependency jar, but I don't know what package I should open my directory to (for spring).
If i put my messages directly under the resources directory where application.properties resides (and adjust my code accordingly), everything works fine!
Any ideas how to make spring.messages.basename work with java11 and custom path???
Comment From: wilkinsona
The code in question is Spring Framework's org.springframework.context.support.ResourceBundleMessageSource
which calls java.util.ResourceBundle.getBundle(String, Locale, ClassLoader, Control)
.
If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.