配置和修改springboot默认国际化文件

SpringBoot默认国际化文件为:classpath:message.properties,如果放在其它文件夹中,则需要在application.properties配置属性spring.messages.basename:

在srpingboot自定义一个国家化文件:

1、在resources目录下创建myconfig.properties
2、修改application.properties或者application.yml文件:
        spring:
          messages:
            basename: myconfig


3、示例:
  myconfig.properties里加入:
message.hello="欢迎使用CRM系统!"

4、在resources的templates下新建index.html


<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<p th:text="#{message.hello}">This text will not be show! </p>

</body>
</html>

原文地址:https://www.cnblogs.com/asker009/p/9212649.html