简体   繁体   English

如何将messages.properties文件移动到单独的文件夹中?

[英]How to move messages.properties files into a separate folder?

Is it possible to place messages.properties and all other locale-specific messages_xx.properties files in a sub-folder of the resources folder in a Spring Boot application? 是否可以将messages.properties和所有其他特定于语言环境的message_xx.properties文件放置在Spring Boot应用程序的resources文件夹的子文件夹中? For example to move them all in langs folder: 例如,将它们全部移到langs文件夹中:

─── 🗁 src
   └─── 🗁 main
       ├─── 🗁 java
       └─── 🗁 resources
           ├─── 🗁 langs
           │   ├─── messages.properties
           │   └─── messages_fa.properties
           └─── ...

Yes, it is possible. 对的,这是可能的。 You just need to add this property in the application.properties or application.yml file: 您只需要在application.properties或application.yml文件中添加此属性:

spring.messages.basename=langs.messages

Here langs is the name of the folder and messages is the base name of files. langs是文件夹的名称, messages是文件的基本名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM