{"id":772,"date":"2023-05-28T02:11:03","date_gmt":"2023-05-27T18:11:03","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=772"},"modified":"2023-05-28T02:11:03","modified_gmt":"2023-05-27T18:11:03","slug":"spring%e6%ba%90%e7%a0%81%e7%b3%bb%e5%88%97%ef%bc%88%e8%a1%a5%e5%85%85%ef%bc%89%ef%bc%9a%e8%af%a6%e8%a7%a3applicationcontext","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/spring-boot\/spring%e6%ba%90%e7%a0%81%e7%b3%bb%e5%88%97%ef%bc%88%e8%a1%a5%e5%85%85%ef%bc%89%ef%bc%9a%e8%af%a6%e8%a7%a3applicationcontext\/","title":{"rendered":"Spring\u6e90\u7801\u7cfb\u5217\uff08\u8865\u5145\uff09\uff1a\u8be6\u89e3ApplicationContext"},"content":{"rendered":"<div class='wxsyncmain'>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-galleryid=\"\" data-ratio=\"0.2777777777777778\"  data-type=\"gif\" data-w=\"1080\" style=\"\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020042413.gif\" 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-galleryid=\"\" data-ratio=\"0.2777777777777778\"  data-type=\"gif\" data-w=\"1080\" style=\"\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020042413.gif\"><\/noscript><\/p>\n<section label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"box-sizing: border-box;\">\n<section label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"box-sizing: border-box;\">\n<section label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin-top: 10px;margin-bottom: 10px;box-sizing: border-box;\">\n<section label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"box-sizing: border-box;text-align: center;\">\n<section label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"display: inline-block;vertical-align: top;padding: 8px 5px 5px 3px;width: 50%;box-sizing: border-box;border-right: 1px solid #a6bde7;\">\n<section style=\"box-sizing: border-box;\">\n<section label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin-top: 0.5em;margin-bottom: 0.5em;box-sizing: border-box;\">\n<section style=\"box-sizing: border-box;width: 4em;height: 4em;display: inline-block;vertical-align: bottom;border-radius: 100%;font-family: PingfangSC-LIGHT,sans-serif;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020040648.jpeg');background-size: cover;background-position: 50% 50%;background-repeat: no-repeat;\"><br  \/><\/section>\n<p><span style=\"font-size: 14px;color: #a6bde7;line-height: 1.6;font-family: PingfangSC-LIGHT,sans-serif;\">JAVA \u5f00\u53d1\u5fae\u6307\u5357<\/span><\/p>\n<\/section>\n<\/section>\n<\/section>\n<section label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"display: inline-block;vertical-align: top;padding: 6px;width: 50%;box-sizing: border-box;\">\n<section style=\"box-sizing: border-box;border-width: 1px;border-style: solid;border-color: rgb(166, 189, 231);padding: 8px 5px;width: 120px;color: rgb(166, 189, 231);margin: auto;line-height: 20px;font-size: 14px;border-radius: 4px;\">\n<p>\u8bfb\u5b8c\u9700\u8981<\/p>\n<section style=\"font-size: 30px;color:#666;line-height: 32px;\">10<\/section>\n<p>\u5206\u949f<\/p>\n<p style=\"font-size: 11px;color:#aaa;padding-top:3px;\">\u901f\u8bfb\u4ec5\u9700 4 \u5206\u949f<\/p>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(0, 0, 0);text-align: center;line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(62, 62, 62);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 20px;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(137, 137, 137);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(62, 62, 62);box-sizing: border-box !important;word-wrap: break-word !important;font-family: PingfangSC-Ultralight,sans-serif;\"><strong style=\"color:rgb(32, 91, 195);\">\/ <\/strong>\u524d\u8a00<strong style=\"color:rgb(32, 91, 195);\"> \/<\/strong><\/span><\/span><\/span><\/span><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u5728\u4e4b\u524d\u7684\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u5bf9 Spring \u6e90\u7801\u4e2d\u7684\u4e00\u4e9b\u6838\u5fc3\u6982\u5ff5\u8fdb\u884c\u4e86\u5206\u6790\u3002\u7531\u4e8e\u7bc7\u5e45\u9650\u5236\uff0c\u6211\u4eec\u5e76\u6ca1\u6709\u8be6\u7ec6\u89e3\u91ca ApplicationContext \u7c7b\u6240\u7ee7\u627f\u7684\u7236\u63a5\u53e3\u53ca\u5176\u4f5c\u7528\u3002\u56e0\u6b64\uff0c\u672c\u6587\u5c06\u5355\u72ec\u4e3a ApplicationContext \u8fdb\u884c\u8be6\u7ec6\u8bf4\u660e\uff0c\u5305\u62ec\u5176\u7ee7\u627f\u7684\u7236\u63a5\u53e3\u53ca\u5176\u4f5c\u7528\u3002<\/span><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(0, 0, 0);text-align: center;line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(62, 62, 62);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 20px;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(137, 137, 137);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(62, 62, 62);box-sizing: border-box !important;word-wrap: break-word !important;font-family: PingfangSC-Ultralight,sans-serif;\"><strong style=\"color:rgb(32, 91, 195);\">\/ <\/strong>ApplicationContext \u7236\u63a5\u53e3<strong style=\"color:rgb(32, 91, 195);\"> \/<\/strong><\/span><\/span><\/span><\/span><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"line-height: 25.6px;max-width: 100%;white-space: pre-wrap;color: rgb(62, 62, 62);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><strong style=\"max-width: 100%;color: rgb(32, 91, 195);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><em style=\"max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 24px;box-sizing: border-box !important;padding-left:4px;word-wrap: break-word !important;font-family: PingFangSC-Semibold,sans-serif;\">1<\/span><\/em><\/strong><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"line-height: 25.6px;max-width: 100%;white-space: pre-wrap;color: rgb(62, 62, 62);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<h2 label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin-top: -10px;font-family: PingfangSC-LIGHT, sans-serif;line-height: 9px;color: white;border-radius: 10px;background-image: linear-gradient(to right, rgb(32, 91, 195) 25%, rgb(166, 189, 231) 10%);background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;\">&nbsp; &nbsp;<\/h2>\n<p style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(137, 137, 137);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><strong style=\"max-width: 100%;color: rgb(62, 62, 62);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 20px;box-sizing: border-box !important;word-wrap: break-word !important;font-family: PingFangSC-Semibold,sans-serif;\"><jncounttag><\/jncounttag>MessageSource<\/span><\/strong><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u5927\u5bb6\u5e94\u8be5\u90fd\u6bd4\u8f83\u719f\u6089 MessageSource\uff0c\u5b83\u7528\u4e8e\u56fd\u9645\u5316\uff0c\u8bb8\u591a\u9879\u76ee\u90fd\u4f1a\u4f7f\u7528\u5b83\u3002\u4f7f\u7528 MessageSource \u7684\u57fa\u672c\u6b65\u9aa4\u5982\u4e0b\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\"> AnnotationConfigApplicationContext applicationContext = <span class=\"code-snippet__keyword\">new<\/span> AnnotationConfigApplicationContext(AppConfig.class);<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\"> <span class=\"code-snippet__built_in\">String<\/span> message = applicationContext.getMessage(<span class=\"code-snippet__string\">\"test\"<\/span>, <span class=\"code-snippet__literal\">null<\/span>, <span class=\"code-snippet__keyword\">new<\/span> Locale(<span class=\"code-snippet__string\">\"en\"<\/span>));<\/span><\/code><code><span class=\"code-snippet_outer\"> System.out.println(message);<\/span><\/code><\/pre>\n<\/section>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u4f60\u9700\u8981\u5728 resources \u8def\u5f84\u4e0b\u521b\u5efa\u76f8\u5e94\u7684\u8bed\u8a00\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u5728\u672c\u6587\u7684\u4ee3\u7801\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86\u201cen\u201d\u8bed\u8a00\uff0c\u56e0\u6b64\u9700\u8981\u521b\u5efa messages_en.properties \u6587\u4ef6\uff0c\u5176\u5185\u5bb9\u5982\u4e0b\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\">test=b<\/span><\/code><\/pre>\n<\/section>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u8fd9\u6837\uff0c\u5f53\u6211\u4eec\u83b7\u53d6\u201ctest\u201d\u8bed\u8a00\u65f6\uff0c\u5c31\u4f1a\u5f97\u5230\u201cb\u201d\u3002<\/span><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"line-height: 25.6px;max-width: 100%;white-space: pre-wrap;color: rgb(62, 62, 62);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><strong style=\"max-width: 100%;color: rgb(32, 91, 195);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><em style=\"max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 24px;box-sizing: border-box !important;padding-left:4px;word-wrap: break-word !important;font-family: PingFangSC-Semibold,sans-serif;\">2<\/span><\/em><\/strong><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"line-height: 25.6px;max-width: 100%;white-space: pre-wrap;color: rgb(62, 62, 62);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<h2 label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin-top: -10px;font-family: PingfangSC-LIGHT, sans-serif;line-height: 9px;color: white;border-radius: 10px;background-image: linear-gradient(to right, rgb(32, 91, 195) 50%, rgb(166, 189, 231) 10%);background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;\">&nbsp; &nbsp;<\/h2>\n<p style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(137, 137, 137);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><strong style=\"max-width: 100%;color: rgb(62, 62, 62);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 20px;box-sizing: border-box !important;word-wrap: break-word !important;font-family: PingFangSC-Semibold,sans-serif;\"><jncounttag><\/jncounttag>ResourcePatternResolver<\/span><\/strong><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">ResourcePatternResolver \u4e3b\u8981\u7528\u4e8e\u83b7\u53d6\u8d44\u6e90\uff0c\u5373\u8d44\u6e90\u52a0\u8f7d\uff0c\u53ef\u4ee5\u52a0\u8f7d\u67d0\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">\/\/ \u521b\u5efa\u4e00\u4e2aSpring\u5bb9\u5668<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">    AnnotationConfigApplicationContext applicationContext = <span class=\"code-snippet__keyword\">new<\/span> AnnotationConfigApplicationContext(AppConfig.class);<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">\/\/    String message = applicationContext.getMessage(\"test\", null, new Locale(\"en\"));<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">\/\/    System.out.println(message);<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">    Resource resource = applicationContext.getResource(<span class=\"code-snippet__string\">\"classpath:spring.properties\"<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">    System.out.println(resource.contentLength());<\/span><\/code><\/pre>\n<\/section>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u9664\u6b64\u4e4b\u5916\uff0cResourcePatternResolver \u8fd8\u6709\u5176\u4ed6\u7528\u6cd5\uff0c\u4f8b\u5982\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">\/\/ \u521b\u5efa\u4e00\u4e2aSpring\u5bb9\u5668<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">    AnnotationConfigApplicationContext applicationContext = <span class=\"code-snippet__keyword\">new<\/span> AnnotationConfigApplicationContext(AppConfig.class);<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">\/\/    String message = applicationContext.getMessage(\"test\", null, new Locale(\"en\"));<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">\/\/    System.out.println(message);<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">    Resource resource = applicationContext.getResource(<span class=\"code-snippet__string\">\"https:\/\/www.baidu.com\"<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">    System.out.println(resource.contentLength());<\/span><\/code><code><span class=\"code-snippet_outer\">    System.out.println(resource.getURL());<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__comment\">\/\/\u8fd8\u53ef\u4ee5\u83b7\u53d6\u591a\u4e2a\u8d44\u6e90<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">    Resource[] resources = applicationContext.getResources(<span class=\"code-snippet__string\">\"classpath:com\/xiaoyu\/*.class\"<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">    Arrays.stream(resources).forEach(System.out::println);<\/span><\/code><\/pre>\n<\/section>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u4ee5\u4e0a\u53ea\u662f\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u8fd8\u9700\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u8c03\u6574\u3002<\/span><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"line-height: 25.6px;max-width: 100%;white-space: pre-wrap;color: rgb(62, 62, 62);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><strong style=\"max-width: 100%;color: rgb(32, 91, 195);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><em style=\"max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 24px;box-sizing: border-box !important;padding-left:4px;word-wrap: break-word !important;font-family: PingFangSC-Semibold,sans-serif;\">3<\/span><\/em><\/strong><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"line-height: 25.6px;max-width: 100%;white-space: pre-wrap;color: rgb(62, 62, 62);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<h2 label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin-top: -10px;font-family: PingfangSC-LIGHT, sans-serif;line-height: 9px;color: white;border-radius: 10px;background-image: linear-gradient(to right, rgb(32, 91, 195) 75%, rgb(166, 189, 231) 10%);background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;\">&nbsp; &nbsp;<\/h2>\n<p style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(137, 137, 137);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><strong style=\"max-width: 100%;color: rgb(62, 62, 62);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 20px;box-sizing: border-box !important;word-wrap: break-word !important;font-family: PingFangSC-Semibold,sans-serif;\"><jncounttag><\/jncounttag>EnvironmentCapable<\/span><\/strong><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u83b7\u53d6\u8fd0\u884c\u65f6\u73af\u5883\u53ef\u4ee5\u4f7f\u7528 ApplicationContext \u7684 getEnvironment \u65b9\u6cd5\uff0c\u5177\u4f53\u7528\u6cd5\u5982\u4e0b\uff1a<\/span><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">\/\/ \u521b\u5efa\u4e00\u4e2aSpring\u5bb9\u5668<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">    AnnotationConfigApplicationContext applicationContext = <span class=\"code-snippet__keyword\">new<\/span> AnnotationConfigApplicationContext(AppConfig.class);<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\">    applicationContext.getEnvironment().getPropertySources().forEach(System.out::println);<\/span><\/code><code><span class=\"code-snippet_outer\">    System.out.println(<span class=\"code-snippet__string\">\"================\"<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">    applicationContext.getEnvironment().getSystemEnvironment().forEach((k, v) -&gt; System.out.println(k + <span class=\"code-snippet__string\">\" : \"<\/span> + v));<\/span><\/code><code><span class=\"code-snippet_outer\">    System.out.println(<span class=\"code-snippet__string\">\"================\"<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">    applicationContext.getEnvironment().getSystemProperties().forEach((k, v) -&gt; System.out.println(k + <span class=\"code-snippet__string\">\" : \"<\/span> + v));<\/span><\/code><code><span class=\"code-snippet_outer\">    System.out.println(<span class=\"code-snippet__string\">\"================\"<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">    System.out.println(applicationContext.getEnvironment().getProperty(<span class=\"code-snippet__string\">\"sun.jnu.encoding\"<\/span>));<\/span><\/code><code><span class=\"code-snippet_outer\">    System.out.println(applicationContext.getEnvironment().getProperty(<span class=\"code-snippet__string\">\"xiaoyu\"<\/span>));<\/span><\/code><\/pre>\n<\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\">@PropertySource(<span class=\"code-snippet__string\">\"classpath:spring.properties\"<\/span>)<\/span><\/code><\/pre>\n<\/section>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u6ce8\u610f\uff0c\u53ef\u4ee5\u4f7f\u7528@PropertySource \u6ce8\u89e3\u5c06 spring.properties \u6dfb\u52a0\u5230\u8fd0\u884c\u65f6\u73af\u5883\uff0c\u7136\u540e\u901a\u8fc7 getProperty \u65b9\u6cd5\u53bb\u83b7\u53d6\u3002<\/span><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"line-height: 25.6px;max-width: 100%;white-space: pre-wrap;color: rgb(62, 62, 62);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><strong style=\"max-width: 100%;color: rgb(32, 91, 195);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><em style=\"max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 24px;box-sizing: border-box !important;padding-left:4px;word-wrap: break-word !important;font-family: PingFangSC-Semibold,sans-serif;\">4<\/span><\/em><\/strong><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"line-height: 25.6px;max-width: 100%;white-space: pre-wrap;color: rgb(62, 62, 62);box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<h2 label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin-top: -10px;font-family: PingfangSC-LIGHT, sans-serif;line-height: 9px;color: white;border-radius: 10px;background-image: linear-gradient(to right, rgb(32, 91, 195) 100%, rgb(166, 189, 231) 10%);background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;\">&nbsp; &nbsp;<\/h2>\n<p style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(137, 137, 137);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><strong style=\"max-width: 100%;color: rgb(62, 62, 62);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 20px;box-sizing: border-box !important;word-wrap: break-word !important;font-family: PingFangSC-Semibold,sans-serif;\"><jncounttag><\/jncounttag>ApplicationEventPublisher<\/span><\/strong><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">ApplicationEventPublisher \u662f\u4e00\u4e2a\u4e8b\u4ef6\u53d1\u5e03\u5668\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 ApplicationContext \u6765\u53d1\u5e03\u4e00\u4e2a\u76f8\u5e94\u7684\u4e8b\u4ef6\uff0c\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">\/\/ \u521b\u5efa\u4e00\u4e2aSpring\u5bb9\u5668<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">    AnnotationConfigApplicationContext applicationContext = <span class=\"code-snippet__keyword\">new<\/span> AnnotationConfigApplicationContext(AppConfig.class);<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__comment\">\/\/\u53d1\u5e03\u81ea\u5df1\u7684\u4e8b\u4ef6<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">    applicationContext.publishEvent(<span class=\"code-snippet__keyword\">new<\/span> MyEvent(<span class=\"code-snippet__string\">\"xiaoyu\"<\/span>));<\/span><\/code><\/pre>\n<\/section>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u5b9a\u4e49\u81ea\u5df1\u7684\u4e8b\u4ef6\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\">public <span class=\"code-snippet__class\"><span class=\"code-snippet__keyword\">class<\/span> <span class=\"code-snippet__title\">MyEvent<\/span> <span class=\"code-snippet__keyword\">extends<\/span> <span class=\"code-snippet__title\">ApplicationEvent<\/span> <\/span>{<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\">  private <span class=\"code-snippet__built_in\">String<\/span> message;<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\">  public MyEvent(<span class=\"code-snippet__built_in\">String<\/span> message) {<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__keyword\">super<\/span>(message);<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__keyword\">this<\/span>.message = message;<\/span><\/code><code><span class=\"code-snippet_outer\">  }<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\">  public <span class=\"code-snippet__built_in\">String<\/span> getMessage() {<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__keyword\">return<\/span> message;<\/span><\/code><code><span class=\"code-snippet_outer\">  }<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\">  public <span class=\"code-snippet__keyword\">void<\/span> setMessage(<span class=\"code-snippet__built_in\">String<\/span> message) {<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__keyword\">this<\/span>.message = message;<\/span><\/code><code><span class=\"code-snippet_outer\">  }<\/span><\/code><code><span class=\"code-snippet_outer\">}<\/span><\/code><\/pre>\n<\/section>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u521b\u5efa\u4e00\u4e2a\u4e8b\u4ef6\u76d1\u542c\u5668\uff0c\u53ef\u4ee5\u76d1\u542c\u6240\u6709\u4e8b\u4ef6\uff0c\u4e5f\u53ef\u4ee5\u5355\u72ec\u76d1\u542c\u81ea\u5df1\u7684\u4e8b\u4ef6\u3002\u5982\u679c\u60f3\u8981\u76d1\u542c\u6240\u6709\u4e8b\u4ef6\uff0c\u76f4\u63a5\u53bb\u6389\u6cdb\u578b\u5373\u53ef\u3002Spring \u7684\u4e8b\u4ef6\u4e5f\u53ef\u4ee5\u76d1\u542c\u5230\uff0c\u56e0\u6b64\u5728\u76d1\u542c\u90e8\u5206\u9700\u8981\u81ea\u5df1\u5224\u65ad\u662f\u4ec0\u4e48\u4e8b\u4ef6\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\">@Component<\/span><\/code><code><span class=\"code-snippet_outer\">public <span class=\"code-snippet__class\"><span class=\"code-snippet__keyword\">class<\/span> <span class=\"code-snippet__title\">MyEventListener<\/span> <span class=\"code-snippet__title\">implements<\/span> <span class=\"code-snippet__title\">ApplicationListener<\/span>&lt;<span class=\"code-snippet__title\">MyEvent<\/span>&gt; <\/span>{<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\">  <span class=\"code-snippet__comment\">\/**<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">   * Handle an application event.<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">   *<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">   * @param event the event to respond to<\/span><\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__comment\">   *\/<\/span><\/span><\/code><code><span class=\"code-snippet_outer\">  @Override<\/span><\/code><code><span class=\"code-snippet_outer\">  public <span class=\"code-snippet__keyword\">void<\/span> onApplicationEvent(MyEvent event) {<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__keyword\">if<\/span> (event <span class=\"code-snippet__keyword\">instanceof<\/span> MyEvent) {<\/span><\/code><code><span class=\"code-snippet_outer\">      System.out.println(((MyEvent) event).getMessage());<\/span><\/code><code><span class=\"code-snippet_outer\">    }<\/span><\/code><code><span class=\"code-snippet_outer\">    System.out.println(event);<\/span><\/code><code><span class=\"code-snippet_outer\">  }<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\">}<\/span><\/code><\/pre>\n<\/section>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(0, 0, 0);text-align: center;line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><br  \/><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(0, 0, 0);text-align: center;line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(62, 62, 62);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 20px;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(137, 137, 137);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(62, 62, 62);box-sizing: border-box !important;word-wrap: break-word !important;font-family: PingfangSC-Ultralight,sans-serif;\"><strong style=\"color:rgb(32, 91, 195);\">\/ <\/strong>OrderComparator<strong style=\"color:rgb(32, 91, 195);\"> \/<\/strong><\/span><\/span><\/span><\/span><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u8fd9\u91cc\u6ce8\u610f\u4e0b\uff0cOrderComparator \u5e76\u4e0d\u662f ApplicationContext \u7684\u7236\u63a5\u53e3\uff0c\u5b83\u662f Spring \u5185\u90e8\u63d0\u4f9b\u7684\u4e00\u79cd\u6bd4\u8f83\u5668\uff0c\u7528\u4e8e\u6392\u5e8f\u5b9e\u73b0\u4e86 Order \u63a5\u53e3\u6216\u8005@Order \u6ce8\u89e3\u7684 bean\u3002\u867d\u7136\u5728\u5de5\u4f5c\u4e2d\u6211\u4eec\u4e5f\u4f1a\u7528\u5230\u6392\u5e8f\uff0c\u4f46\u5355\u72ec\u5199\u4e00\u7bc7\u6587\u7ae0\u53ef\u80fd\u5e76\u4e0d\u5fc5\u8981\uff0c\u56e0\u6b64\u5728\u8fd9\u91cc\u7b80\u5355\u63d0\u4e00\u4e0b\u3002<\/span><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u4ed6\u662f Spring \u5185\u90e8\u63d0\u4f9b\u7684\u4e00\u79cd\u6bd4\u8f83\u5668\uff0c\u7528\u4e8e\u6392\u5e8f\u5b9e\u73b0\u4e86 order \u63a5\u53e3\u6216\u8005@order \u6ce8\u89e3\uff0c\u9996\u5148\u5b9a\u4e49\u4e24\u4e2a\u5177\u4f53\u7684 bean\uff0c\u5177\u4f53\u7528\u6cd5\u5982\u4e0b\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\">public class First implements Ordered {<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\">\t@Override<\/span><\/code><code><span class=\"code-snippet_outer\">\tpublic int getOrder() {<\/span><\/code><code><span class=\"code-snippet_outer\">\t\treturn 1;<\/span><\/code><code><span class=\"code-snippet_outer\">\t}<\/span><\/code><code><span class=\"code-snippet_outer\">}<\/span><\/code><\/pre>\n<\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\">public <span class=\"code-snippet__class\"><span class=\"code-snippet__keyword\">class<\/span> <span class=\"code-snippet__title\">Second<\/span> <span class=\"code-snippet__title\">implements<\/span> <span class=\"code-snippet__title\">Ordered<\/span> <\/span>{<\/span><\/code><code><span class=\"code-snippet_outer\"><br  \/><\/span><\/code><code><span class=\"code-snippet_outer\">  @Override<\/span><\/code><code><span class=\"code-snippet_outer\">  public int getOrder() {<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__keyword\">return<\/span> <span class=\"code-snippet__number\">2<\/span>;<\/span><\/code><code><span class=\"code-snippet_outer\">  }<\/span><\/code><code><span class=\"code-snippet_outer\">}<\/span><\/code><\/pre>\n<\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\">First first = <span class=\"code-snippet__keyword\">new<\/span> First();<\/span><\/code><code><span class=\"code-snippet_outer\">    Second second = <span class=\"code-snippet__keyword\">new<\/span> Second();<\/span><\/code><code><span class=\"code-snippet_outer\">    Arrays.asList(first, second).stream().sorted(OrderComparator.INSTANCE).forEach(System.out::println);<\/span><\/code><\/pre>\n<\/section>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u8fd9\u6837\u5c31\u4f1a\u5347\u5e8f\u6392\u5e8f\uff0c\u6570\u503c\u8d8a\u5c0f\u8d8a\u5728\u524d\u9762\uff0c\u5982\u679c\u4f7f\u7528\u7684\u662f\u6ce8\u89e3\u5f62\u5f0f\u7684@order\uff0c\u5219\u4f7f\u7528\u4e0b\u9762\u7684\u5b9e\u4f8b\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\">First first = new First();<\/span><\/code><code><span class=\"code-snippet_outer\">\t\tSecond second = new Second();<\/span><\/code><code><span class=\"code-snippet_outer\">\t\tArrays.asList(first, second).stream().sorted(AnnotationAwareOrderComparator.INSTANCE).forEach(System.out::println);<\/span><\/code><\/pre>\n<\/section>\n<p><br  \/><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u6ce8\u610f\uff0cOrderComparator \u53ea\u9002\u7528\u4e8e\u5b9e\u73b0\u4e86 Ordered \u63a5\u53e3\u6216\u8005@Order \u6ce8\u89e3\u7684 bean\uff0c\u5982\u679c\u9700\u8981\u5bf9\u5176\u4ed6\u7c7b\u578b\u7684\u5bf9\u8c61\u8fdb\u884c\u6392\u5e8f\uff0c\u53ef\u4ee5\u4f7f\u7528\u5176\u4ed6\u6bd4\u8f83\u5668\u3002<\/span><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(0, 0, 0);text-align: center;line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(62, 62, 62);line-height: 25.6px;min-height: 1em;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;font-size: 20px;box-sizing: border-box !important;word-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(137, 137, 137);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;color: rgb(62, 62, 62);box-sizing: border-box !important;word-wrap: break-word !important;font-family: PingfangSC-Ultralight,sans-serif;\"><strong style=\"color:rgb(32, 91, 195);\">\/ <\/strong>\u7ed3\u8bed<strong style=\"color:rgb(32, 91, 195);\"> \/<\/strong><\/span><\/span><\/span><\/span><\/p>\n<p label=\"Converted by KNB Formatter from Jason Ng https:\/\/knb.im\/mp\" style=\"margin: 20px;max-width: 100%;white-space: pre-wrap;color: rgb(43, 43, 43);line-height: 1.5;box-sizing: border-box !important;overflow-wrap: break-word !important;\"><span style=\"max-width: 100%;line-height: 28px;box-sizing: border-box !important;word-wrap: break-word !important;letter-spacing:1px;font-size:15px;font-family: PingfangSC-LIGHT,sans-serif;\">\u81f3\u6b64\uff0cSpring \u7684\u6838\u5fc3\u6982\u5ff5\u89e3\u6790\u544a\u4e00\u6bb5\u843d\uff0c\u4f46\u8fd9\u53ea\u662f\u4e00\u4e2a\u5f00\u59cb\uff0c\u540e\u7eed\u6211\u4eec\u5c06\u6df1\u5165\u7406\u89e3 Spring \u7684\u6e90\u7801\u3002\u56e0\u6b64\uff0c\u5efa\u8bae\u4ed4\u7ec6\u67e5\u770b Spring \u7684\u6838\u5fc3\u5173\u952e\u7c7b\uff0c\u5bf9\u4e8e\u540e\u7eed\u67e5\u770b Spring \u6e90\u7801\u4f1a\u975e\u5e38\u6709\u5e2e\u52a9\u3002\u540c\u65f6\uff0c\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u591a\u5173\u6ce8 Spring \u6846\u67b6\uff0c\u52a0\u6df1\u5bf9\u5176\u7406\u89e3\u548c\u638c\u63e1\u3002<\/span><\/p>\n<section><mp-common-profile class=\"js_uneditable custom_select_card mp_profile_iframe\" data-pluginname=\"mpprofile\" data-weui-theme=\"light\" data-id=\"MzUyNTE4MTY2Mw==\" data-headimg=\"http:\/\/mmbiz.qpic.cn\/mmbiz_png\/cjE6VxWuSEEkjhu2aCCVelz7EibaQriaJCpK36qK0QqjyLiatWJDjeGKu3vam4TOYDibbNHCIlH8snt1MwGYyIYnFQ\/0?wx_fmt=png\" data-nickname=\"JAVA \u5f00\u53d1\u5fae\u6307\u5357\" data-alias=\"javaDev8848\" data-signature=\"\u4ece\u6e90\u7801\u5e95\u5c42\u5f00\u59cb\u5256\u6790\uff0c\u4e86\u89e3\u4e00\u4e2a\u77e5\u8bc6\u70b9\u7684\u4f5c\u7528\u4ee5\u53ca\u5206\u6790\u5de5\u4f5c\u53ca\u9762\u8bd5\u4e2d\u5e38\u7528\u7684\u6280\u672f\" data-from=\"0\" data-is_biz_ban=\"0\"><\/mp-common-profile><\/section>\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:                 JAVA \u5f00\u53d1\u5fae\u6307\u5357              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>JAVA \u5f00\u53d1\u5fae\u6307\u5357 \u8bfb\u5b8c\u9700\u8981 10 \u5206\u949f \u901f\u8bfb\u4ec5\u9700 4 \u5206\u949f \/ \u524d\u8a00 \/ \u5728\u4e4b\u524d\u7684\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u5bf9 Spring \u6e90\u7801\u4e2d\u7684\u4e00 &#8230;<\/p>\n","protected":false},"author":2,"featured_media":770,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-772","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring-boot"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020040611-150x150.jpeg","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020042413.gif","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020040611-300x127.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020040611.jpeg","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020042413.gif","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020040611-300x127.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020040611.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020040611.jpeg","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020042413.gif","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528020042413.gif","id":"image1"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Spring Boot","post_date":"2023-05-27","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":784,"next_post_id":715,"next_post_title":"Spring @DependsOn\u6ce8\u89e3\u89e3\u6790","previous_post_id":853,"previous_post_title":"Spring \u2469 AOP \u521b\u5efa\u4ee3\u7406\u5bf9\u8c61\u8be6\u89e3","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/772","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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=772"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/772\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/770"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}