{"id":1942,"date":"2023-06-19T18:07:43","date_gmt":"2023-06-19T10:07:43","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=1942"},"modified":"2023-06-19T18:07:43","modified_gmt":"2023-06-19T10:07:43","slug":"spring%e5%9b%bd%e9%99%85%e5%8c%96","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/java\/spring%e5%9b%bd%e9%99%85%e5%8c%96\/","title":{"rendered":"Spring\u56fd\u9645\u5316"},"content":{"rendered":"<div class='wxsyncmain'>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin-right: 8px;margin-bottom: 1.5em;margin-left: 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5728\u5b66\u4e60Spring\u56fd\u9645\u5316\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u6765\u770b\u4e00\u4e0bJava\u4e2d\u63d0\u4f9b\u7684\u56fd\u9645\u5316\u652f\u6301\u3002<\/p>\n<h4 style=\"font-size: 1em;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(15, 76, 129);\">Java \u56fd\u9645\u5316\u652f\u6301<\/h4>\n<h4 style=\"font-size: 1em;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(15, 76, 129);\">ResourceBundle<\/h4>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5c06\u8d44\u6e90\u7ed1\u5b9a\u5728\u7279\u5b9a\u533a\u57df\u7684\u5bf9\u8c61\u4e2d\uff0c\u7136\u540e\u6211\u4eec\u901a\u8fc7\u8fd0\u884c\u65f6\u6307\u5b9a\u7684\u533a\u57df\u5730\u5740\u627e\u5230\u7279\u5b9a\u7684\u8d44\u6e90\u7ed1\u5b9a\u5bf9\u8c61\u53d6\u51fa\u503c\uff0c\u901a\u5e38\u60c5\u51b5\uff0c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ResourceBundle<\/code>\u652f\u6301<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">peoperties<\/code>\u548c\u4f7f\u7528Java\u5bf9\u8c61\u7ed1\u5b9a\u533a\u57df\u8d44\u6e90\u7684\u4e24\u79cd\u65b9\u5f0f\uff0c\u4e0b\u9762\u7b80\u5355\u6f14\u793a\u4e00\u4e0b\u4f7f\u7528\u65b9\u5f0f\uff1a<\/p>\n<ul style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;<strong style=\"line-height: 1.75;color: rgb(15, 76, 129);\">\u4f7f\u7528<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">properties<\/code>\u6587\u4ef6\u65b9\u5f0f\u7ed1\u5b9a<\/strong><\/p>\n<\/li>\n<\/ul>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5148\u5728resource\u76ee\u5f55\u4e0b\u9762\u521b\u5efa\u4e09\u4e2a<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">properties<\/code>\u6587\u4ef6\uff0c\u6ce8\u610f\uff0c\u6587\u4ef6\u540d\u524d\u534a\u90e8\u5206\u662f\u76f8\u540c\u7684\uff0c\u540e\u534a\u90e8\u5206\u662f\u56fa\u5b9a\u7684\uff0c\u4e3b\u8981\u662f\u5404\u5730\u533a\u7684\u540d\u79f0\u4ee3\u7801\uff0c\u8be6\u60c5\u503c\u53ef\u4ee5\u5230<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">Locale<\/code>\u5bf9\u8c61\u4e2d\u53c2\u7167\u3002<\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">my_en_US.properties<\/code>:<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(209, 154, 102);\">cancelKey<\/span>=<span style=\"color: rgb(152, 195, 121);\">cancel<\/span><\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">my_zh_CN.properties<\/code>:<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(209, 154, 102);\">cancelKey<\/span>=<span style=\"color: rgb(152, 195, 121);\">u53D6u6D88<\/span><\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">my.properties<\/code><\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(209, 154, 102);\">cancelKey<\/span>=<span style=\"color: rgb(152, 195, 121);\">default&nbsp;cancel<\/span><\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><strong style=\"line-height: 1.75;color: rgb(15, 76, 129);\">\u6d4b\u8bd5\uff1a<\/strong><\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u901a\u8fc7\u914d\u7f6e<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">Locale<\/code>\u6240\u5c5e\u5730\u533a\uff0c\u6211\u4eec\u4f1a\u5230\u5bf9\u5e94\u7684\u4e0d\u540c\u7684\u6587\u4ef6\u4e2d\u53d6\u503c<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ResourceBundleDemo<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">static<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">void<\/span>&nbsp;<span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]&nbsp;args)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u672c\u5730\u73af\u5883\u5730\u5740\u9ed8\u8ba4\u662fzh_CN\u7684<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">ResourceBundle<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">defaultBundle<\/span>&nbsp;=&nbsp;ResourceBundle.getBundle(<span style=\"color: rgb(152, 195, 121);\">\"my\"<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u6253\u5370\uff1a\u53d6\u6d88<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(defaultBundle.getString(<span style=\"color: rgb(152, 195, 121);\">\"cancelKey\"<\/span>));<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">ResourceBundle<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">usBundle<\/span>&nbsp;=&nbsp;ResourceBundle.getBundle(<span style=\"color: rgb(152, 195, 121);\">\"my\"<\/span>,&nbsp;Locale.US);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u6253\u5370\uff1acancel<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(usBundle.getString(<span style=\"color: rgb(152, 195, 121);\">\"cancelKey\"<\/span>));<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">ResourceBundle<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">ukBundle<\/span>&nbsp;=&nbsp;ResourceBundle.getBundle(<span style=\"color: rgb(152, 195, 121);\">\"my\"<\/span>,&nbsp;Locale.UK);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u6253\u5370\uff1a\u53d6\u6d88<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(ukBundle.getString(<span style=\"color: rgb(152, 195, 121);\">\"cancelKey\"<\/span>));<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<blockquote style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;border-left: none;padding: 1em;border-radius: 8px;background: rgb(247, 247, 247);margin: 2em 8px;\">\n<p style=\"line-height: 1.75;font-size: 1em;letter-spacing: 0.1em;color: rgb(80, 80, 80);\">\u8bf4\u660e\uff1a\u5982\u4e0a\u9762\u793a\u4f8b\u4e2d\uff0c\u5982\u679c\u662f\u4e2d\u6587\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u5e76\u4e14\u672a\u6307\u5b9aLocale\u65f6\uff0c\u7a0b\u5e8f\u4f1a\u9996\u5148\u5728classpath\u4e0b\u5bfb\u627e<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">my_zh_CN.properties<\/code>\u6587\u4ef6\uff0c\u82e5<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">my_zh_CN.properties<\/code>\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u5219\u53d6\u627e<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">my_zh.properties<\/code>\uff0c\u5982\u8fd8\u662f\u4e0d\u5b58\u5728\uff0c\u7ee7\u7eed\u5bfb\u627e<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">my.properties<\/code>,\u82e5\u90fd\u627e\u4e0d\u5230\u5c31\u629b\u51fa\u5f02\u5e38\u3002\u5982\u679c\u8bbe\u7f6e\u4e86\u7684\u5730\u533a\u672a\u627e\u5230\u5bf9\u5e94\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5219\u4f1a\u4ee5\u672c\u5730\u7684\u6765\u8fdb\u884c\u89e3\u6790\u3002<\/p>\n<\/blockquote>\n<ul style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;<strong style=\"line-height: 1.75;color: rgb(15, 76, 129);\">Java\u5bf9\u8c61\u8fdb\u884c\u7ed1\u5b9a<\/strong><\/p>\n<\/li>\n<\/ul>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">Java\u5bf9\u8c61\u7ed1\u5b9a\u7684\u4e00\u4e2a\u6838\u5fc3\u63a5\u53e3\u662f<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ListResourceBundle<\/code>\uff0c\u6240\u6709\u901a\u8fc7\u5bf9\u8c61\u7ed1\u5b9a\u7684\u90fd\u8981\u5b9e\u73b0\u6539\u5bf9\u8c61\uff0c\u6539\u5bf9\u8c61\u4e3b\u8981\u8fd4\u56de\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u7684\u5f62\u5f0f\u6765\u6a21\u62df\u4e86properties\u4e2d\u7684\u90a3\u79cdkey-value\u7684\u5f62\u5f0f\u3002<\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e0b\u9762\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u4f7f\u7528\u65b9\u5f0f\uff1a<\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5982properties\u4e2d\u4e00\u6837\uff0c\u6211\u4eec\u9996\u5148\u6211\u4eec\u5148\u521b\u5efa\u5982\u4e0b\u51e0\u4e2a\u5bf9\u8c61\uff0c\u5bf9\u8c61\u547d\u540d\u65b9\u5f0f\u548cproperties\u4e00\u6837\uff1a<\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MyResourceBundle_zh_CN:<\/code><\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">MyResourceBundle_zh_CN<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">extends<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ListResourceBundle<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Override<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">protected<\/span>&nbsp;Object[][]&nbsp;getContents()&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[][]{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<span style=\"color: rgb(152, 195, 121);\">\"OkKey\"<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"\u786e\u5b9a\"<\/span>},<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<span style=\"color: rgb(152, 195, 121);\">\"CancelKey\"<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"\u53d6\u6d88\"<\/span>}<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;};<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MyResourceBundle_en_US:<\/code><\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">MyResourceBundle_en_US<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">extends<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ListResourceBundle<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Override<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">protected<\/span>&nbsp;Object[][]&nbsp;getContents()&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[][]{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<span style=\"color: rgb(152, 195, 121);\">\"OkKey\"<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"OK\"<\/span>},<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<span style=\"color: rgb(152, 195, 121);\">\"CancelKey\"<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"Cancel\"<\/span>}<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;};<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><strong style=\"line-height: 1.75;color: rgb(15, 76, 129);\">\u6d4b\u8bd5\uff1a<\/strong><\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ListResourceBundleDemo<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">static<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">void<\/span>&nbsp;<span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]&nbsp;args)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u672c\u5730\u73af\u5883\u5730\u5740\u9ed8\u8ba4\u662fzh_CN\u7684<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">ResourceBundle<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">defaultResources<\/span>&nbsp;=&nbsp;ResourceBundle.getBundle(<span style=\"color: rgb(152, 195, 121);\">\"cn.phshi.resourcebundle.MyResourceBundle\"<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u6253\u5370\uff1a\u786e\u5b9a<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(defaultResources.getString(<span style=\"color: rgb(152, 195, 121);\">\"OkKey\"<\/span>));<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">ResourceBundle<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">usResources<\/span>&nbsp;=&nbsp;ResourceBundle.getBundle(<span style=\"color: rgb(152, 195, 121);\">\"cn.phshi.resourcebundle.MyResourceBundle\"<\/span>,&nbsp;Locale.US);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u6253\u5370\uff1aOK<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(usResources.getString(<span style=\"color: rgb(152, 195, 121);\">\"OkKey\"<\/span>));<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">ResourceBundle<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">ukResources<\/span>&nbsp;=&nbsp;ResourceBundle.getBundle(<span style=\"color: rgb(152, 195, 121);\">\"cn.phshi.resourcebundle.MyResourceBundle\"<\/span>,&nbsp;Locale.UK);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u6253\u5370\uff1a\u786e\u5b9a<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(ukResources.getString(<span style=\"color: rgb(152, 195, 121);\">\"OkKey\"<\/span>));<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5728\u672a\u5339\u914d\u5230\u5bf9\u5e94\u533a\u57df\u7684\u914d\u7f6e\u65f6\uff0c\u5339\u914d\u65b9\u5f0f\u548c\u4e0a\u9762\u7684prperties\u4e00\u6837\u3002<\/p>\n<h4 style=\"font-size: 1em;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(15, 76, 129);\">\u6587\u672c\u683c\u5f0f\u5316<\/h4>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">Java\u6587\u672c\u683c\u5f0f\u5316\u7684\u6838\u5fc3\u63a5\u53e3\u662f<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageFormat<\/code>\uff0c\u4ed6\u5728Java\u4e2d\u63d0\u4f9b\u4e86\u4e00\u79cd\u4ee5\u4e0e\u8bed\u8a00\u65e0\u5173\u7684\u65b9\u5f0f\u751f\u6210\u8fde\u63a5\u6d88\u606f\u7684\u65b9\u6cd5\u3002\u4f7f\u7528\u6b64\u9009\u9879\u53ef\u4ee5\u6784\u9020\u4e3a\u6700\u7ec8\u7528\u6237\u663e\u793a\u7684\u6d88\u606f\u3002<\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e0b\u9762\u6211\u4eec\u4e3b\u8981\u8bb2\u7684\u662f<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageFormat<\/code>\u7684\u7b80\u5355\u5b9e\u7528\u65b9\u5f0f\uff0c\u9996\u5148\uff0c\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e0b\u7b80\u5355\u793a\u4f8b\uff1a<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">MessageFormatDemo<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">static<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">void<\/span>&nbsp;<span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]&nbsp;args)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">MessageFormat<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">messageFormat<\/span>&nbsp;=&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">MessageFormat<\/span>(<span style=\"color: rgb(152, 195, 121);\">\"The&nbsp;current&nbsp;time&nbsp;is\uff1a{0,date,full}\"<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">String<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">format<\/span>&nbsp;=&nbsp;messageFormat.format(<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[]{<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Date<\/span>()});<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u8f93\u51fa\uff1aThe&nbsp;current&nbsp;time&nbsp;is\uff1a2023\u5e745\u67081\u65e5&nbsp;\u661f\u671f\u4e00<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(format);<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4ece\u4e0a\u9762\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\uff0c\u5728\u521b\u5efa<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageFormat<\/code>\u65f6\u5019\u6211\u4eec\u4f20\u5165\u9700\u8981\u683c\u5f0f\u5316\u7684\u5b57\u7b26\u4e32\uff0c\u5b57\u7b26\u4e32\u4e2d\u7684<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">{0,date,full}<\/code>\u4e2d\u7684\u5177\u4f53\u5185\u5bb9\uff0c\u800c\u5927\u62ec\u53f7\u4e2d\u6709\u4e09\u4e2a\u53c2\u6570<\/p>\n<ul style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;\u7b2c\u4e00\u4e2a\u662f\u683c\u5f0f\u5316\u5b57\u7b26\u7684\u5b9a\u4f4d\uff0c\u4e5f\u5c31\u662f\u4e0b\u9762\u6570\u7ec4\u4e2d\u7684\u4e0b\u6807\u5b9a\u4f4d<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u683c\u5f0f\u5316\u7c7b\u578b\uff0c\u652f\u6301<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">number<\/code>\uff0c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">date<\/code>\uff0c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\"> time<\/code>\uff0c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">choice<\/code><\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u683c\u5f0f\u5316\u98ce\u683c\uff0c\u652f\u6301<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">short<\/code>\uff0c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">medium<\/code>\uff0c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">long<\/code>\uff0c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">full <\/code>\uff0c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">integer<\/code>\uff0c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">currency<\/code>\uff0c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">percent<\/code>\uff0c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">SubformatPattern<\/code><\/p>\n<\/li>\n<\/ul>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e0b\u9762\u6211\u4eec\u6f14\u793a\u4e00\u4e0b\u57fa\u672c\u4f7f\u7528\uff1a<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">MessageFormatDemo<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">static<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">void<\/span>&nbsp;<span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]&nbsp;args)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;1\u3001\u7b80\u5355\u683c\u5f0f\u5316<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">MessageFormat<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">messageFormat<\/span>&nbsp;=&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">MessageFormat<\/span>(<span style=\"color: rgb(152, 195, 121);\">\"The&nbsp;current&nbsp;time&nbsp;is\uff1a{0,date,full}\"<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">String<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">format<\/span>&nbsp;=&nbsp;messageFormat.format(<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[]{<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Date<\/span>()});<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(format);<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;2\u3001\u91cd\u7f6epattern<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;messageFormat.applyPattern(<span style=\"color: rgb(152, 195, 121);\">\"At&nbsp;{1,time}&nbsp;on&nbsp;{1,date,full},&nbsp;there&nbsp;was&nbsp;{2}&nbsp;on&nbsp;planet&nbsp;{0,number,integer}\"<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;format&nbsp;=&nbsp;messageFormat.format(<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[]{<span style=\"color: rgb(209, 154, 102);\">7<\/span>,&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Date<\/span>(),&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"a&nbsp;disturbance&nbsp;in&nbsp;the&nbsp;Force\"<\/span>});<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(format);<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;3\u3001\u91cd\u7f6eLocale<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;messageFormat.setLocale(Locale.ENGLISH);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;messageFormat.applyPattern(<span style=\"color: rgb(152, 195, 121);\">\"At&nbsp;{1,time}&nbsp;on&nbsp;{1,date,full},&nbsp;there&nbsp;was&nbsp;{2}&nbsp;on&nbsp;planet&nbsp;{0,number,integer}\"<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;format&nbsp;=&nbsp;messageFormat.format(<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[]{<span style=\"color: rgb(209, 154, 102);\">7<\/span>,&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Date<\/span>(),&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"a&nbsp;disturbance&nbsp;in&nbsp;the&nbsp;Force\"<\/span>});<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(format);<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;4\u3001\u6839\u636e\u53c2\u6570\u7d22\u5f15\u6765\u8bbe\u7f6e&nbsp;Pattern<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;messageFormat.setFormat(<span style=\"color: rgb(209, 154, 102);\">1<\/span>,<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">SimpleDateFormat<\/span>(<span style=\"color: rgb(152, 195, 121);\">\"YYYY-MM-dd&nbsp;HH:mm:ss\"<\/span>));<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;format&nbsp;=&nbsp;messageFormat.format(<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[]{<span style=\"color: rgb(209, 154, 102);\">7<\/span>,&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Date<\/span>(),&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"a&nbsp;disturbance&nbsp;in&nbsp;the&nbsp;Force\"<\/span>});<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(format);<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;5\u3001ChoiceFormat\u683c\u5f0f\u5316<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;messageFormat.applyPattern(<span style=\"color: rgb(152, 195, 121);\">\"The&nbsp;disk&nbsp;\"{1}\"&nbsp;contains&nbsp;{0}.\"<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u6807\u8bc6\u53c2\u6570\u53c2\u6570\u4e3a0\u5c55\u793ano&nbsp;files\uff0c1\u5c55\u793a\uff1aone&nbsp;file\uff0c2\u6216\u8005\u5176\u4ed6\u90fd\u5c55\u793a&nbsp;\u6570\u91cf&nbsp;files<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">ChoiceFormat<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">fileform<\/span>&nbsp;=&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ChoiceFormat<\/span>(<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">double<\/span>[]{<span style=\"color: rgb(209, 154, 102);\">0<\/span>,&nbsp;<span style=\"color: rgb(209, 154, 102);\">1<\/span>,&nbsp;<span style=\"color: rgb(209, 154, 102);\">2<\/span>},&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">String<\/span>[]{<span style=\"color: rgb(152, 195, 121);\">\"no&nbsp;files\"<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"one&nbsp;file\"<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"{0,number}&nbsp;files\"<\/span>});<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;messageFormat.setFormatByArgumentIndex(<span style=\"color: rgb(209, 154, 102);\">0<\/span>,&nbsp;fileform);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(messageFormat.format(<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[]{<span style=\"color: rgb(209, 154, 102);\">0<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"MyDisk\"<\/span>}));<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(messageFormat.format(<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[]{<span style=\"color: rgb(209, 154, 102);\">1<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"MyDisk\"<\/span>}));<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(messageFormat.format(<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[]{<span style=\"color: rgb(209, 154, 102);\">2<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"MyDisk\"<\/span>}));<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(messageFormat.format(<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[]{<span style=\"color: rgb(209, 154, 102);\">100<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"MyDisk\"<\/span>}));<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\">The&nbsp;current&nbsp;time&nbsp;is\uff1a2023\u5e745\u67081\u65e5&nbsp;\u661f\u671f\u4e00<br  \/>At&nbsp;11:07:15&nbsp;on&nbsp;2023\u5e745\u67081\u65e5&nbsp;\u661f\u671f\u4e00,&nbsp;there&nbsp;was&nbsp;a&nbsp;disturbance&nbsp;in&nbsp;the&nbsp;Force&nbsp;on&nbsp;planet&nbsp;7<br  \/>At&nbsp;11:07:15&nbsp;AM&nbsp;on&nbsp;Monday,&nbsp;May&nbsp;1,&nbsp;2023,&nbsp;there&nbsp;was&nbsp;a&nbsp;disturbance&nbsp;in&nbsp;the&nbsp;Force&nbsp;on&nbsp;planet&nbsp;7<br  \/>At&nbsp;11:07:15&nbsp;AM&nbsp;on&nbsp;2023-05-01&nbsp;11:07:15,&nbsp;there&nbsp;was&nbsp;a&nbsp;disturbance&nbsp;in&nbsp;the&nbsp;Force&nbsp;on&nbsp;planet&nbsp;7<br  \/>The&nbsp;disk&nbsp;\"MyDisk\"&nbsp;contains&nbsp;no&nbsp;files.<br  \/>The&nbsp;disk&nbsp;\"MyDisk\"&nbsp;contains&nbsp;one&nbsp;file.<br  \/>The&nbsp;disk&nbsp;\"MyDisk\"&nbsp;contains&nbsp;2&nbsp;files.<br  \/>The&nbsp;disk&nbsp;\"MyDisk\"&nbsp;contains&nbsp;100&nbsp;files.<\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u66f4\u591a\u4f7f\u7528\u65b9\u5f0f\u53ef\u4ee5\u53c2\u7167Java\u6e90\u7801\u4e2d<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageFormat<\/code>\u7684\u76f8\u5173\u6ce8\u91ca\u3002<\/p>\n<h4 style=\"font-size: 1em;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(15, 76, 129);\">Spring\u56fd\u9645\u5316<\/h4>\n<blockquote style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;border-left: none;padding: 1em;border-radius: 8px;background: rgb(247, 247, 247);margin: 2em 8px;\">\n<p style=\"line-height: 1.75;font-size: 1em;letter-spacing: 0.1em;color: rgb(80, 80, 80);\">\u5728Spring\u4e2d\uff0c\u4ed6\u5bf9Java\u4e2d\u63d0\u4f9b\u7684<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ResourceBundle + MessageFormat<\/code>\u7ec4\u5408\u8d77\u6765\u5171\u540c\u5b9e\u73b0\u7684\u56fd\u9645\u5316\u3002<\/p>\n<p style=\"line-height: 1.75;font-size: 1em;letter-spacing: 0.1em;color: rgb(80, 80, 80);\">\u9700\u8981\u5173\u6ce8\u7684\u90e8\u5206\uff1a<\/p>\n<ul style=\"line-height: 1.75;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;Spring\u56fd\u9645\u5316\u7684\u6838\u5fc3\u63a5\u53e3\u662f<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageSource<\/code><\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;Spring\u4e2d\u7684<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageSource<\/code>\u4e5f\u91c7\u7528\u4e86\u7c7b\u4f3c\u4e8e<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">BeanFactory<\/code>\u7684\u5206\u5c42\u7ed3\u6784\uff08\u5b58\u5728\u7236\u7ea7<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageSource<\/code>\uff09\uff0c\u7236\u7ea7\u62bd\u8c61\u63a5\u53e3\u4e3a<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">HierarchicalMessageSource<\/code><\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;Spring\u5185\u7f6e\u4e86\u51e0\u4e2a\u9ed8\u8ba4\u7684\u56fd\u9645\u5316\u8d44\u6e90\u5b9e\u73b0\uff0c\u5176\u4e2d\u5e38\u7528\u7684\u4e24\u4e2a\u5b9e\u73b0\u6709<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ReloadableResourceBundleMessageSource<\/code>\u548c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ResourceBundleMessageSource<\/code>\uff0c\u4e24\u4e2a\u90fd\u662f\u57fa\u4e8e<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">AbstractMessageSource<\/code>\u62bd\u8c61\u5b9e\u73b0\u7684<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ReloadableResourceBundleMessageSource<\/code>: \u63d0\u4f9b\u5916\u90e8\u8d44\u6e90\uff08<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">properties<\/code>\u3001<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">xml<\/code>\uff09\u52a0\u8f7d\u7684\u56fd\u9645\u5316\u5b9e\u73b0\u65b9\u6848\uff0c\u5e76\u63d0\u4f9b\u4e86\u5b9a\u65f6\u5237\u65b0\u529f\u80fd\uff0c\u5141\u8bb8\u5728\u4e0d\u91cd\u542f\u7cfb\u7edf\u7684\u60c5\u51b5\u4e0b\uff0c\u66f4\u65b0\u8d44\u6e90\u7684\u4fe1\u606f<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ResourceBundleMessageSource:<\/code>&nbsp;\u63d0\u4f9b&nbsp;<strong style=\"line-height: 1.75;color: rgb(15, 76, 129);\">Java\u5bf9\u8c61\u8fdb\u884c\u7ed1\u5b9a<\/strong>&nbsp;\u8fdb\u884c\u56fd\u9645\u5316\u7ed1\u5b9a\u7684\u65b9\u5f0f<\/p>\n<\/li>\n<\/ul>\n<\/blockquote>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u73b0\u5728\uff0c\u6211\u4eec\u57fa\u4e8e\u4e0a\u9762\u6211\u4eec\u9700\u8981\u91cd\u70b9\u5173\u6ce8\u7684\u90e8\u5206\u6765\u8fdb\u884c\u4e00\u4e00\u67e5\u770b\uff1a<\/p>\n<h4 style=\"font-size: 1em;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(15, 76, 129);\">\u6838\u5fc3\u63a5\u53e3<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageSource<\/code><\/h4>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">Spring\u56fd\u9645\u5316\u7684\u6838\u5fc3\u63a5\u53e3\u662f<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageSource<\/code>\uff0c\u4ed6\u7684\u5b9e\u73b0\u4e5f\u6bd4\u8f83\u7b80\u5355\uff0c\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u8be5\u63a5\u53e3\uff1a<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">interface<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">MessageSource<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/**<br  \/>&nbsp;&nbsp;&nbsp;*&nbsp;\u83b7\u53d6\u56fd\u9645\u5316\u4fe1\u606f<br  \/>&nbsp;&nbsp;&nbsp;*&nbsp;<span style=\"color: rgb(198, 120, 221);\">@param<\/span>&nbsp;code&nbsp;\u8868\u793a\u56fd\u9645\u5316\u8d44\u6e90\u4e2d\u7684\u5c5e\u6027\u540d\uff1b<br  \/>&nbsp;&nbsp;&nbsp;*&nbsp;<span style=\"color: rgb(198, 120, 221);\">@param<\/span>&nbsp;args\u7528\u4e8e\u4f20\u9012\u683c\u5f0f\u5316\u4e32\u5360\u4f4d\u7b26\u6240\u7528\u7684\u8fd0\u884c\u53c2\u6570\uff1b<br  \/>&nbsp;&nbsp;&nbsp;*&nbsp;<span style=\"color: rgb(198, 120, 221);\">@param<\/span>&nbsp;defaultMessage&nbsp;\u5f53\u5728\u8d44\u6e90\u627e\u4e0d\u5230\u5bf9\u5e94\u5c5e\u6027\u540d\u65f6\uff0c\u8fd4\u56dedefaultMessage\u53c2\u6570\u6240\u6307\u5b9a\u7684\u9ed8\u8ba4\u4fe1\u606f\uff1b<br  \/>&nbsp;&nbsp;&nbsp;*&nbsp;<span style=\"color: rgb(198, 120, 221);\">@param<\/span>&nbsp;locale&nbsp;\u8868\u793a\u672c\u5730\u5316\u5bf9\u8c61<br  \/>&nbsp;&nbsp;&nbsp;*\/<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span><br  \/>&nbsp;&nbsp;String&nbsp;<span style=\"color: rgb(97, 174, 238);\">getMessage<\/span>(String&nbsp;code,&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span>&nbsp;Object[]&nbsp;args,&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span>&nbsp;String&nbsp;defaultMessage,&nbsp;Locale&nbsp;locale);<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/**<br  \/>&nbsp;&nbsp;&nbsp;*&nbsp;\u4e0e\u4e0a\u9762\u7684\u65b9\u6cd5\u7c7b\u4f3c\uff0c\u53ea\u4e0d\u8fc7\u5728\u627e\u4e0d\u5230\u8d44\u6e90\u4e2d\u5bf9\u5e94\u7684\u5c5e\u6027\u540d\u65f6\uff0c\u76f4\u63a5\u629b\u51faNoSuchMessageException\u5f02\u5e38<br  \/>&nbsp;&nbsp;&nbsp;*\/<\/span><br  \/>&nbsp;&nbsp;String&nbsp;<span style=\"color: rgb(97, 174, 238);\">getMessage<\/span>(String&nbsp;code,&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span>&nbsp;Object[]&nbsp;args,&nbsp;Locale&nbsp;locale)&nbsp;<span style=\"color: rgb(198, 120, 221);\">throws<\/span>&nbsp;NoSuchMessageException;<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/**<br  \/>&nbsp;&nbsp;&nbsp;*&nbsp;<span style=\"color: rgb(198, 120, 221);\">@param<\/span>&nbsp;MessageSourceResolvable&nbsp;\u5c06\u5c5e\u6027\u540d\u3001\u53c2\u6570\u6570\u7ec4\u4ee5\u53ca\u9ed8\u8ba4\u4fe1\u606f\u5c01\u88c5\u8d77\u6765\uff0c\u5b83\u7684\u529f\u80fd\u548c\u7b2c\u4e00\u4e2a\u65b9\u6cd5\u76f8\u540c<br  \/>&nbsp;&nbsp;&nbsp;*\/<\/span><br  \/>&nbsp;&nbsp;String&nbsp;<span style=\"color: rgb(97, 174, 238);\">getMessage<\/span>(MessageSourceResolvable&nbsp;resolvable,&nbsp;Locale&nbsp;locale)&nbsp;<span style=\"color: rgb(198, 120, 221);\">throws<\/span>&nbsp;NoSuchMessageException;<br  \/>}<\/code><\/pre>\n<h4 style=\"font-size: 1em;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(15, 76, 129);\">\u56fd\u9645\u5316\u5206\u5c42\u7ed3\u6784\u7684<\/h4>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u56fd\u9645\u5316<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageSource<\/code>\u4e5f\u88ab\u8bbe\u5b9a\u4e3a\u5982<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">BeanFactory<\/code>\u7684\u4e00\u6837\uff0c\u5177\u6709\u5206\u5c42\u7ed3\u6784\uff0c\u5bf9\u4e8e\u56fd\u9645\u5316\u7684\u5206\u5c42\u7ed3\u6784\u7684\u5177\u4f53\u5b9e\u73b0\u662f<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">HierarchicalMessageSource<\/code>\u7ed3\u63a5\u53e3\uff0c\u8be5\u63a5\u53e3\u4e5f\u6bd4\u8f83\u7b80\u5355<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">interface<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">HierarchicalMessageSource<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">extends<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">MessageSource<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/**<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u8bbe\u7f6e\u7236\u7ea7\u7684\u56fd\u9645\u5316\u8d44\u6e90\u5bf9\u8c61<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">void<\/span>&nbsp;<span style=\"color: rgb(97, 174, 238);\">setParentMessageSource<\/span>(<span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span>&nbsp;MessageSource&nbsp;parent);<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/**<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u8fd4\u56de\u7236\u7ea7\u7684\u56fd\u9645\u5316\u8d44\u6e90\u5bf9\u8c61<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;MessageSource&nbsp;<span style=\"color: rgb(97, 174, 238);\">getParentMessageSource<\/span>();<br  \/>}<\/code><\/pre>\n<h4 style=\"font-size: 1em;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(15, 76, 129);\">Spring\u9488\u5bf9\u56fd\u9645\u5316\u7684\u62bd\u8c61<\/h4>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e0a\u9762\u8bf4\u8fc7\uff0cSpring\u5185\u7f6e\u4e86\u51e0\u4e2a\u9ed8\u8ba4\u7684\u56fd\u9645\u5316\u8d44\u6e90\u5b9e\u73b0\uff0c\u5176\u4e2d\u5e38\u7528\u7684\u4e24\u4e2a\u5b9e\u73b0\u662f<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ReloadableResourceBundleMessageSource<\/code>\u548c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ResourceBundleMessageSource<\/code>\uff0c\u4ed6\u4eec\u4e24\u4e2a\u90fd\u662f\u57fa\u4e8e<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">AbstractMessageSource<\/code>\u62bd\u8c61\u5b9e\u73b0\u7684\uff0c\u800c\u4e14\uff0c\u5982\u679c\u6211\u4eec\u60f3\u8981\u5b9e\u73b0\u81ea\u5b9a\u4e49\u7684\u56fd\u9645\u5316\u65b9\u5f0f\u4e5f\u53ef\u4ee5\u7ee7\u627f\u8be5\u62bd\u8c61\u65b9\u6cd5\uff0c\u4e0b\u9762\u6211\u4eec\u6765\u7b80\u5355\u770b\u4e00\u4e0b\u8be5\u62bd\u8c61\u65b9\u6cd5\u7684\u6838\u5fc3\u5185\u5bb9\u3002<\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u9488\u5bf9\u4e0e<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">AbstractMessageSource<\/code>\uff0c\u6211\u4eec\u9009\u53d6<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageSource<\/code>\u63a5\u53e3\u4e2d\u7684\u5176\u4e2d\u4e00\u4e2a<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">getMessage<\/code>\u65b9\u6cd5\u6765\u5206\u6790\uff0c\u5176\u4ed6\u65b9\u6cd5\u4e5f\u662f\u5dee\u4e0d\u591a\u7684\u3002<\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">getMessage:<\/code><\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u5b9e\u73b0\u4e86HierarchicalMessageSource\uff0c\u652f\u6301\u56fd\u9645\u5316\u5206\u5c42\u7ed3\u6784<\/span><br  \/><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">abstract<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">AbstractMessageSource<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">extends<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">MessageSourceSupport<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">implements<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">HierarchicalMessageSource<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u6ce8\u610f\u6539\u65b9\u6cd5\u88abfinal\u4fee\u9970\uff0c\u4e0d\u80fd\u91cd\u5199\u4e86<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Override<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">final<\/span>&nbsp;String&nbsp;<span style=\"color: rgb(97, 174, 238);\">getMessage<\/span>(String&nbsp;code,&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span>&nbsp;Object[]&nbsp;args,&nbsp;Locale&nbsp;locale)&nbsp;<span style=\"color: rgb(198, 120, 221);\">throws<\/span>&nbsp;NoSuchMessageException&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u5185\u90e8\u83b7\u53d6\u6d88\u606f\u7684\u65b9\u5f0f<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">String<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">msg<\/span>&nbsp;=&nbsp;getMessageInternal(code,&nbsp;args,&nbsp;locale);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">if<\/span>&nbsp;(msg&nbsp;!=&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;msg;<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u901a\u8fc7code\u67e5\u8be2\u8fd4\u56de\u9ed8\u8ba4\u6d88\u606f\uff08\u5b50\u7c7b\u4e5f\u53ef\u4ee5\u91cd\u5199\u8be5\u65b9\u6cd5\u8bbe\u7f6e\u9ed8\u8ba4\u7684\u6d88\u606f\u5185\u5bb9\uff09<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">String<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">fallback<\/span>&nbsp;=&nbsp;getDefaultMessage(code);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">if<\/span>&nbsp;(fallback&nbsp;!=&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;fallback;<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">throw<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">NoSuchMessageException<\/span>(code,&nbsp;locale);<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">getMessageInternal<\/code>:<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">protected<\/span>&nbsp;String&nbsp;<span style=\"color: rgb(97, 174, 238);\">getMessageInternal<\/span>(<span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span>&nbsp;String&nbsp;code,&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span>&nbsp;Object[]&nbsp;args,&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span>&nbsp;Locale&nbsp;locale)&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;Object[]&nbsp;argsToUse&nbsp;=&nbsp;args;<br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">if<\/span>&nbsp;(!isAlwaysUseMessageFormat()&nbsp;&amp;&amp;&nbsp;ObjectUtils.isEmpty(args))&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u5982\u679c\u662f\u5141\u8bb8\u4e0d\u4f7f\u7528\u6d88\u606f\u683c\u5f0f\u5e76\u4e14\u5360\u4f4d\u7b26\u53c2\u6570\u4e3a\u7a7a\u7684\u65f6\u5019\u76f4\u63a5\u8fd4\u56de\u7684\u5b57\u7b26\u4e32<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u5176\u5b9e\u5185\u90e8\u4e5f\u662f\u6267\u884c\u7684resolveCode(code,&nbsp;locale)\uff0c\u53ea\u4e0d\u8fc7\u683c\u5f0f\u5316\u65f6\u5019arg\u4e3a\u7a7a\u6570\u7ec4<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">String<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">message<\/span>&nbsp;=&nbsp;resolveCodeWithoutArguments(code,&nbsp;locale);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">if<\/span>&nbsp;(message&nbsp;!=&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;message;<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br  \/>&nbsp;&nbsp;}&nbsp;<span style=\"color: rgb(198, 120, 221);\">else<\/span>&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u5148\u56fd\u9645\u5316\u53c2\u6570<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;argsToUse&nbsp;=&nbsp;resolveArguments(args,&nbsp;locale);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u901a\u8fc7code\u83b7\u5f97\u56fd\u9645\u5316\u7684\u6d88\u606f\uff08\u62bd\u8c61\u65b9\u6cd5\uff0c\u5b50\u7c7b\u901a\u8fc7\u5b9e\u73b0\u8be5\u65b9\u6cd5\u5b9e\u73b0\u56fd\u9645\u5316\uff09<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">MessageFormat<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">messageFormat<\/span>&nbsp;=&nbsp;resolveCode(code,&nbsp;locale);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">if<\/span>&nbsp;(messageFormat&nbsp;!=&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">synchronized<\/span>&nbsp;(messageFormat)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u683c\u5f0f\u5316\u8f93\u51fa<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;messageFormat.format(argsToUse);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br  \/>&nbsp;&nbsp;}<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u901a\u8fc7code\u5230\u516c\u5171\u6d88\u606f\u4e2d\u67e5\u627e<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">Properties<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">commonMessages<\/span>&nbsp;=&nbsp;getCommonMessages();<br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">if<\/span>&nbsp;(commonMessages&nbsp;!=&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">String<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">commonMessage<\/span>&nbsp;=&nbsp;commonMessages.getProperty(code);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">if<\/span>&nbsp;(commonMessage&nbsp;!=&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;formatMessage(commonMessage,&nbsp;args,&nbsp;locale);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br  \/>&nbsp;&nbsp;}<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u672a\u627e\u5230\u6d88\u606f\uff0c\u5230\u7236\u7ea7\u4e2d\u7ee7\u7eed\u67e5\u627e<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;getMessageFromParent(code,&nbsp;argsToUse,&nbsp;locale);<br  \/>}<br  \/><br  \/><span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span><br  \/><span style=\"color: rgb(198, 120, 221);\">protected<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">abstract<\/span>&nbsp;MessageFormat&nbsp;<span style=\"color: rgb(97, 174, 238);\">resolveCode<\/span>(String&nbsp;code,&nbsp;Locale&nbsp;locale);<\/code><\/pre>\n<blockquote style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;border-left: none;padding: 1em;border-radius: 8px;background: rgb(247, 247, 247);margin: 2em 8px;\">\n<p style=\"line-height: 1.75;font-size: 1em;letter-spacing: 0.1em;color: rgb(80, 80, 80);\">\u6240\u4ee5\u901a\u5e38\u6211\u4eec\u9700\u8981\u5b9e\u73b0\u81ea\u5b9a\u4e49\u7684\u56fd\u9645\u5316\u7684\u65f6\u5019\u53ea\u9700\u8981\u7ee7\u627f<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">AbstractMessageSource<\/code>\uff0c\u5e76\u4e14\u91cd\u5199<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">resolveCode<\/code>\u8fd9\u4e2a\u65b9\u6cd5\u5373\u53ef\u3002<\/p>\n<\/blockquote>\n<h4 style=\"font-size: 1em;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(15, 76, 129);\">Spring\u5185\u7f6e\u56fd\u9645\u5316\u5b9e\u73b0<\/h4>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u770b\u4e00\u4e0bSpring\u5185\u7f6e\u7684<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ReloadableResourceBundleMessageSource<\/code>\u548c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ResourceBundleMessageSource<\/code>\u4e24\u4e2a\u56fd\u9645\u5316\u5b9e\u73b0\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u4f46\u662f\uff0c\u5728\u4f7f\u7528\u7684\u65f6\u5019\uff0c\u6211\u4eec\u5fc5\u987b\u9075\u5b88\u4e00\u4e2aSpring\u4e2d\u9488\u5bf9\u4e8e\u56fd\u9645\u5316\u8d44\u6e90\u5b9e\u73b0\u7684\u7ea6\u5b9a\u3002<\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><mark>\u6ce8\u610f\uff1aSpring\u4e2d\u8981\u6c42\u6ce8\u5165IOC\u4e2d\u7684\u56fd\u9645\u5316\u8d44\u6e90\u7684Bean\u540d\u79f0\u5fc5\u987b\u662f<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">messageSource<\/code>\u3002<\/mark><\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e3a\u4ec0\u4e48\u8bf4Spring\u4e2d\u7ea6\u5b9a\u4e86\u56fd\u9645\u5316\u8d44\u6e90\u7684Bean\u540d\u79f0\u5fc5\u987b\u662f<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">messageSource<\/code>\uff0c\u9996\u5148\u6211\u4eec\u8981\u77e5\u9053\uff0c\u5176\u5b9eSpring\u7684\u4e0a\u4e0b\u6587\u672c\u8eab\u5c31\u662f\u4e00\u4e2a<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageSource<\/code>\u7684\u5b9e\u73b0\u7c7b\u3002\u5982\u4e0b\u56fe\u6211\u4eec\u53ef\u4ee5\u770b\u5230<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">AbstractApplicationContext<\/code>\u5bf9\u8c61\u662f\u5b9e\u73b0\u4e86<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MessageSource<\/code>\u8fd9\u4e2a\u5bf9\u8c61\u7684\u3002<\/p>\n<figure style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;color: rgb(63, 63, 63);\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.3113207547169811\"  data-type=\"png\" data-w=\"2756\" style=\"line-height: 1.75;border-radius: 4px;display: block;margin: 0.1em auto 0.5em;\" title=\"null\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050300645.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.3113207547169811\"  data-type=\"png\" data-w=\"2756\" style=\"line-height: 1.75;border-radius: 4px;display: block;margin: 0.1em auto 0.5em;\" title=\"null\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050300645.png\"><\/noscript><figcaption style=\"text-align: center;line-height: 1.75;color: rgb(136, 136, 136);font-size: 0.8em;\">image-20230505223148658<\/figcaption><\/figure>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4f46\u662f\uff0c\u5728Spring\u4e0a\u4e0b\u6587\u4e2d\uff0c\u672c\u8eab\u5e76\u6ca1\u6709\u5bf9\u56fd\u9645\u5316\u8d44\u6e90\u5b9e\u73b0\uff0c\u800c\u662f\u8fdb\u884c\u4e86\u4e00\u4e2a\u4ee3\u7406\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u770b\u4e0b\u9762\u4ee3\u7801\uff1a<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">abstract<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">AbstractApplicationContext<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">extends<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">DefaultResourceLoader<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">implements<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ConfigurableApplicationContext<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u56fd\u9645\u5316\u8d44\u6e90\u7684\u4ee3\u7406<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">private<\/span>&nbsp;MessageSource&nbsp;messageSource;<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Override<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;String&nbsp;<span style=\"color: rgb(97, 174, 238);\">getMessage<\/span>(String&nbsp;code,&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Nullable<\/span>&nbsp;Object[]&nbsp;args,&nbsp;Locale&nbsp;locale)&nbsp;<span style=\"color: rgb(198, 120, 221);\">throws<\/span>&nbsp;NoSuchMessageException&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u59d4\u6258\u7ed9\u4ee3\u7406\u5bf9\u8c61\u6267\u884c<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;getMessageSource().getMessage(code,&nbsp;args,&nbsp;locale);<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6211\u4eec\u77e5\u9053\u4e86Spring\u7684\u56fd\u9645\u5316\u5176\u5b9e\u662f\u59d4\u6258\u7ed9\u4e86<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">messageSource<\/code>\u8fd9\u4e2a\u5c5e\u6027\u8fdb\u884c\u6267\u884c\u7684\uff0c\u90a3\u4e48\u4e0b\u9762\u6211\u4eec\u5c31\u6765\u770b\u770b<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">messageSource<\/code>\u8fd9\u4e2a\u5c5e\u6027\u7684\u521d\u59cb\u5316\u3002\u4ed6\u7684\u521d\u59cb\u5316\u4e3b\u8981\u662f\u5728<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">AbstractApplicationContext#initMessageSource()<\/code>\u8fd9\u4e2a\u65b9\u6cd5\u4e2d\u3002<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">static<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">final<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">String<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">MESSAGE_SOURCE_BEAN_NAME<\/span>&nbsp;=&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"messageSource\"<\/span>;<br  \/><br  \/><span style=\"color: rgb(198, 120, 221);\">protected<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">void<\/span>&nbsp;<span style=\"color: rgb(97, 174, 238);\">initMessageSource<\/span>()&nbsp;{<br  \/>&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">ConfigurableListableBeanFactory<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">beanFactory<\/span>&nbsp;=&nbsp;getBeanFactory();<br  \/>&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;MESSAGE_SOURCE_BEAN_NAME\u4fbf\u662f\u524d\u9762\u6240\u8bf4\u7684messageSource\uff0c\u6240\u4ee5\u53ea\u6709IOC\u5bb9\u5668\u4e2d\u5b58\u5728\u8fd9\u4e2a\u5bf9\u8c61\u624d\u4f1a\u8fdb\u5165\u65b9\u6cd5\u4e2d<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">if<\/span>&nbsp;(beanFactory.containsLocalBean(MESSAGE_SOURCE_BEAN_NAME))&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u590d\u5236messageSource\u4e3a\u5bb9\u5668\u4e2d\u540d\u79f0\u4e3amessageSource\u8fd9\u4e2a\u5bf9\u8c61<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(230, 192, 123);\">this<\/span>.messageSource&nbsp;=&nbsp;beanFactory.getBean(MESSAGE_SOURCE_BEAN_NAME,&nbsp;MessageSource.class);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">if<\/span>&nbsp;(<span style=\"color: rgb(230, 192, 123);\">this<\/span>.parent&nbsp;!=&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>&nbsp;&amp;&amp;&nbsp;<span style=\"color: rgb(230, 192, 123);\">this<\/span>.messageSource&nbsp;<span style=\"color: rgb(198, 120, 221);\">instanceof<\/span>&nbsp;HierarchicalMessageSource)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">HierarchicalMessageSource<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">hms<\/span>&nbsp;=&nbsp;(HierarchicalMessageSource)&nbsp;<span style=\"color: rgb(230, 192, 123);\">this<\/span>.messageSource;<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">if<\/span>&nbsp;(hms.getParentMessageSource()&nbsp;==&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u5982\u679cmessageSource\u662f\u5206\u5c42\u7ed3\u6784\u5e76\u4e14\u4e0d\u5b58\u5728\u4e0a\u7ea7\uff0c\u5219\u8bbe\u7f6e\u4ed6\u7684\u4e0a\u7ea7\u4e3a\u5f53\u524dSpring\u4e0a\u4e0b\u6587\u7684parent<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hms.setParentMessageSource(getInternalParentMessageSource());<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br  \/>&nbsp;&nbsp;}<br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">else<\/span>&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u5426\u5219\u6ce8\u518c\u4e00\u4e2a\u9ed8\u8ba4\u7684MessageSource<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">DelegatingMessageSource<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">dms<\/span>&nbsp;=&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">DelegatingMessageSource<\/span>();<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;dms.setParentMessageSource(getInternalParentMessageSource());<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(230, 192, 123);\">this<\/span>.messageSource&nbsp;=&nbsp;dms;<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;beanFactory.registerSingleton(MESSAGE_SOURCE_BEAN_NAME,&nbsp;<span style=\"color: rgb(230, 192, 123);\">this<\/span>.messageSource);<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u77e5\u9053\u4e86\u4e0a\u9762\u8fd9\u4e9b\u63a5\u4e0b\u6765\u6211\u4eec\u5c31\u6765\u7b80\u5355\u6f14\u793a\u4e00\u4e0b<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ReloadableResourceBundleMessageSource<\/code>\u548c<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ResourceBundleMessageSource<\/code>\u7684\u4f7f\u7528<\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><strong style=\"line-height: 1.75;color: rgb(15, 76, 129);\">ReloadableResourceBundleMessageSource:<\/strong><\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u9996\u5148\u5728resource\u76ee\u5f55\u4e0b\u521b\u5efa\u4e09\u4e2a\u6587\u4ef6\uff1a<\/p>\n<ul style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">my.properties<\/code><\/p>\n<\/li>\n<\/ul>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\">cancelKey=default&nbsp;cancel<\/code><\/pre>\n<ul style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">my_en_US.properties<\/code><\/p>\n<\/li>\n<\/ul>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\">cancelKey=cancel<\/code><\/pre>\n<ul style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">my_zh_CN.properties<\/code><\/p>\n<\/li>\n<\/ul>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\">cancelKey=u53D6u6D88<\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u7b80\u5355\u5b9e\u7528\u65b9\u5f0f\uff1a<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ReloadableMessageSourceDemo<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">static<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">void<\/span>&nbsp;<span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]&nbsp;args)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">AnnotationConfigApplicationContext<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">context<\/span>&nbsp;=&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">AnnotationConfigApplicationContext<\/span>();<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;context.register(ReloadableMessageSourceDemo.class);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;context.refresh();<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">String<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">cancelKey<\/span>&nbsp;=&nbsp;context.getMessage(<span style=\"color: rgb(152, 195, 121);\">\"cancelKey\"<\/span>,&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>,&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u6253\u5370\uff1a\u53d6\u6d88<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(cancelKey);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;context.close();<br  \/>&nbsp;&nbsp;}<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u6ce8\u610f\u6ce8\u518c\u7684Bean\u540d\u79f0<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Bean(AbstractApplicationContext.MESSAGE_SOURCE_BEAN_NAME)<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;MessageSource&nbsp;<span style=\"color: rgb(97, 174, 238);\">messageSource<\/span>()&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">ReloadableResourceBundleMessageSource<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">messageSource<\/span>&nbsp;=&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ReloadableResourceBundleMessageSource<\/span>();<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;messageSource.setBasename(<span style=\"color: rgb(152, 195, 121);\">\"classpath:my\"<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u5237\u65b0\u7f13\u5b58\u65f6\u95f4<\/span><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;messageSource.setCacheSeconds(<span style=\"color: rgb(209, 154, 102);\">10<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;messageSource;<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<blockquote style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;border-left: none;padding: 1em;border-radius: 8px;background: rgb(247, 247, 247);margin: 2em 8px;\">\n<p style=\"line-height: 1.75;font-size: 1em;letter-spacing: 0.1em;color: rgb(80, 80, 80);\">\u6ce8\u610f\u867d\u7136<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ReloadableResourceBundleMessageSource<\/code>\u662f\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">setCacheSeconds<\/code>\u6765\u8bbe\u7f6e\u7f13\u5b58\u52a0\u8f7d\u6587\u4ef6\u7684\u7f13\u5b58\u65f6\u95f4\uff0c\u4f46\u662f\uff0c\u4ed6\u662f\u5b58\u5728\u7740\u9650\u5236\u7684\uff0c<strong style=\"line-height: 1.75;color: rgb(15, 76, 129);\">\u5b98\u65b9\u4e25\u683c\u8868\u9762\uff0c\u8bf7\u52ff\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528<\/strong>&nbsp;\u3002\u6240\u4ee5\u5982\u679c\u60f3\u8981\u5b9e\u73b0\u52a8\u6001\u52a0\u8f7d\u7684\u56fd\u9645\u5316\u65b9\u5f0f\u53ea\u80fd\u591f\u81ea\u5df1\u53bb\u5b9e\u73b0<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">AbstractMessageSource<\/code>\u5b9e\u73b0\u3002<\/p>\n<\/blockquote>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><strong style=\"line-height: 1.75;color: rgb(15, 76, 129);\">ResourceBundleMessageSource:<\/strong><\/p>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u9996\u5148\u5148\u521b\u5efa\u8bfb\u53d6\u7684\u8d44\u6e90\u5bf9\u8c61\uff1a<\/p>\n<ul style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MyResourceBundle_en_US<\/code><\/p>\n<\/li>\n<\/ul>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">MyResourceBundle_en_US<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">extends<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ListResourceBundle<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Override<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">protected<\/span>&nbsp;Object[][]&nbsp;getContents()&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[][]{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<span style=\"color: rgb(152, 195, 121);\">\"OkKey\"<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"OK\"<\/span>},<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<span style=\"color: rgb(152, 195, 121);\">\"CancelKey\"<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"Cancel\"<\/span>}<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;};<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<ul style=\"font-size: 14px;letter-spacing: normal;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022&nbsp;<code style=\"white-space:pre-wrap;line-height: 1.75;font-size: 12.6px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MyResourceBundle_zh_CN<\/code><\/p>\n<\/li>\n<\/ul>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">MyResourceBundle_zh_CN<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">extends<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ListResourceBundle<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Override<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">protected<\/span>&nbsp;Object[][]&nbsp;getContents()&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">Object<\/span>[][]{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<span style=\"color: rgb(152, 195, 121);\">\"OkKey\"<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"\u786e\u5b9a\"<\/span>},<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<span style=\"color: rgb(152, 195, 121);\">\"CancelKey\"<\/span>,&nbsp;<span style=\"color: rgb(152, 195, 121);\">\"\u53d6\u6d88\"<\/span>}<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;};<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<p style=\"font-size: 14px;white-space: normal;text-align: left;line-height: 1.75;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u7b80\u5355\u5b9e\u7528\u65b9\u5f0f\uff1a<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;overflow-x: auto;border-radius: 8px;padding: 1em;margin: 10px 8px;\"><code style=\"line-height: 1.75;font-family: Menlo, &quot;Operator Mono&quot;, Consolas, Monaco, monospace;white-space: nowrap;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">class<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ResourceBundleMessageSourceDemo<\/span>&nbsp;{<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">static<\/span>&nbsp;<span style=\"color: rgb(198, 120, 221);\">void<\/span>&nbsp;<span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]&nbsp;args)&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">AnnotationConfigApplicationContext<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">context<\/span>&nbsp;=&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">AnnotationConfigApplicationContext<\/span>();<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;context.register(ResourceBundleMessageSourceDemo.class);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;context.refresh();<br  \/><br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">String<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">cancelKey<\/span>&nbsp;=&nbsp;context.getMessage(<span style=\"color: rgb(152, 195, 121);\">\"OkKey\"<\/span>,&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>,&nbsp;<span style=\"color: rgb(86, 182, 194);\">null<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(cancelKey);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;context.close();<br  \/>&nbsp;&nbsp;}<br  \/><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/&nbsp;\u6ce8\u610f\u6ce8\u518c\u7684Bean\u540d\u79f0<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(97, 174, 238);\">@Bean(AbstractApplicationContext.MESSAGE_SOURCE_BEAN_NAME)<\/span><br  \/>&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">public<\/span>&nbsp;MessageSource&nbsp;<span style=\"color: rgb(97, 174, 238);\">messageSource<\/span>()&nbsp;{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(209, 154, 102);\">ResourceBundleMessageSource<\/span>&nbsp;<span style=\"color: rgb(209, 154, 102);\">messageSource<\/span>&nbsp;=&nbsp;<span style=\"color: rgb(198, 120, 221);\">new<\/span>&nbsp;<span style=\"color: rgb(230, 192, 123);\">ResourceBundleMessageSource<\/span>();<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;messageSource.setBasename(<span style=\"color: rgb(152, 195, 121);\">\"cn.phshi.resourcebundle.MyResourceBundle\"<\/span>);<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: rgb(198, 120, 221);\">return<\/span>&nbsp;messageSource;<br  \/>&nbsp;&nbsp;}<br  \/>}<\/code><\/pre>\n<p><br  \/><\/p>\n<p style=\"display: none;\"><mp-style-type data-value=\"3\"><\/mp-style-type><\/p>\n<blockquote>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7:                 \u7a0b\u5e8f\u733fPhshi              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u5728\u5b66\u4e60Spring\u56fd\u9645\u5316\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u6765\u770b\u4e00\u4e0bJava\u4e2d\u63d0\u4f9b\u7684\u56fd\u9645\u5316\u652f\u6301\u3002 Java \u56fd\u9645\u5316\u652f\u6301 ResourceBundle  &#8230;<\/p>\n","protected":false},"author":1,"featured_media":1940,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[2,6],"tags":[],"class_list":["post-1942","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-spring"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050258334-150x150.jpeg","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050300645.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050258334-300x128.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050258334-1024x437.jpeg","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050300645.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050258334-300x128.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050258334-1024x437.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050258334.jpeg","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050300645.png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528050300645.png","id":"image1"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Java","post_date":"2023-06-19","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":285,"next_post_id":1923,"next_post_title":"\u8be6\u89e3Spring Bean\u751f\u547d\u5468\u671f","previous_post_id":1949,"previous_post_title":"Spring \u4e4b \u4e8b\u52a1\u5931\u8d25\u7684\u51e0\u79cd\u5e38\u89c1\u573a\u666f","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/1942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1942"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/1942\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/1940"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}