My Situation
I want to use ResourceBundleMessageSource in my project (Maven/SpringBoot). But I dont get it to work and found no other help online.
The Error
o.s.c.s.ResourceBundleMessageSource : ResourceBundle [resources/label] not found for MessageSource: Can't find bundle for base name resources/label, locale de_DE
My Data:
in my configurations.java:
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource source = new ResourceBundleMessageSource();
source.setBasenames("Resources");
source.setUseCodeAsDefaultMessage(true);
return source;
}
My App.java:
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
My structure is:
Main
|
|App.java (to Start the App)
|Resources
\
| "locale de_DE.properties"
CodePudding user response:
I found my mistake thanks to @M.Deinum.
Solution
- I removed the Bean.
- Renamed the file
messages.properties
and made a second one for german. - Put these files in src\resources.
No it works fine.
CodePudding user response:
Create different files with names appending the locale.
en_US
or jp_JP
or en_BR
The files will look like below.
messages.properties
--> Default
messages_br_DE.properties
messages_en_US.properties
This should fix the problem. In your ResourceBundle you can pass the locale.