workerjoe
workerjoe

Reputation: 2663

How can I configure a Spring Boot app to use two message properties files?

I have a Spring Boot app that pulls messages from messages.properties and its language-specific partners (e.g. messages_fr.properties for French users). I'd like to add a second set of messages files, for messages that are shared across several of my organization's applications. Let's call it commonmessages.properties (and commonmessages_fr.properties etc.).

How can I tell Spring Boot to use both files for messages?

Upvotes: 0

Views: 1762

Answers (1)

workerjoe
workerjoe

Reputation: 2663

As seen in an example in this Spring Boot "features" overview, you can set the property spring.messages.basename in application.properties or application.yml to a comma-separated string.

In this case:

spring.messages.basename=messages,commonmessages

EDIT: I did a bit of testing and it seems like the entry listed first has precedence, i.e., if messages of the same name are found in both files, the app will use the one from messages and not the one from commonmessages.

Upvotes: 3

Related Questions