4

I’ve succeed to externalize my spring-boot configuration file (application.properties) in a config folder when I run my spring-boot application as a unix service with the help of the official spring documentation https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

I have also some i18n messages.properties files in my src/main/resources that I would like to externalize in the same config folder but I failed to do it. I’ve tried a lot of things, like playing with spring.messages.basename but unfortunately, it doesn’t work.

I’m using the latest version of spring-boot, and use auto configure mode with the default i18n properties name messages.

What am I missing??? thanks for your help.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224

3 Answers3

4

Just a few notes:

  1. classpath:message - will always lookup embeded message_xxx files
  2. classpath:/message and classpath:message are equivalent
  3. file:message - will lookup jar's external current directory e.g. ./message_en.properties <- this is what you want

  4. file:/message - you have to put your message files to root "/" to make it work

  5. use notation file:config/message if you need to put in config folder together with your ./config/application.properties

0

I think you need a leading slash.

Try: spring.messages.basename=classpath:/config/messages

d01
  • 1
  • 2
0

I think, resource bundle is default to classpath. So there's no need to append it. just go straight to your folder location from classpath.

Try this: **assuming your config is inside static folder

spring.messages.basename=static/config/messages

ZaiZac
  • 13
  • 4