{"id":722,"date":"2023-05-28T02:10:40","date_gmt":"2023-05-27T18:10:40","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=722"},"modified":"2023-05-28T02:10:40","modified_gmt":"2023-05-27T18:10:40","slug":"springboot%e5%a4%9a%e6%95%b0%e6%8d%ae%e6%ba%90%e5%88%87%e6%8d%a2%e5%b0%b1%e6%98%af%e8%bf%99%e4%b9%88%e7%ae%80%e5%8d%95","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/spring-boot\/springboot%e5%a4%9a%e6%95%b0%e6%8d%ae%e6%ba%90%e5%88%87%e6%8d%a2%e5%b0%b1%e6%98%af%e8%bf%99%e4%b9%88%e7%ae%80%e5%8d%95\/","title":{"rendered":"SpringBoot\u591a\u6570\u636e\u6e90\u5207\u6362\u5c31\u662f\u8fd9\u4e48\u7b80\u5355"},"content":{"rendered":"<div class='wxsyncmain'>\n<h2 style=\" box-sizing: border-box;padding-left: 10px;margin-top: 30px;margin-bottom: 30px;color: rgb(19, 92, 224); font-size: 20px;border-left: 4px solid;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255); \">\u7801\u519c\u5728\u56e7\u9014<\/h2>\n<blockquote style=\"box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;margin-top: 2em;margin-bottom: 2em;padding: 2px 20px;border-left-width: 4px;border-left-color: rgb(178, 174, 197);color: rgb(89, 89, 89);font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;\">\n<p style=\"box-sizing: border-box;color: rgb(102, 102, 102);line-height: 2;\"><span style=\"background-color: rgb(255, 249, 249);\">\u6bcf\u5f53\u6674\u7a7a\u4e07\u91cc\u7684\u65f6\u5019\uff0c\u5929\u7a7a\u4f9d\u7136\u662f\u6e5b\u84dd\u7684\uff0c\u591c\u91cc\u6211\u8fd8\u662f\u4f1a\u4ef0\u671b\u8fd9\u96be\u5f97\u7684\u661f\u7a7a\u4fef\u77b0<\/span>\u504c<span style=\"background-color: rgb(255, 249, 249);\">\u5927\u7684\u57ce\u5e02\uff0c\u4e07\u5bb6\u706f\u706b\u4e2d\u5374\u6ca1\u6709\u4e00\u76cf\u706f\u662f\u4e3a\u6211\u4eae\u7740\u7684\u3002<\/span><\/p>\n<\/blockquote>\n<h2 style=\" box-sizing: border-box;padding-left: 10px;margin-top: 30px;margin-bottom: 30px;color: rgb(19, 92, 224); font-size: 20px;border-left: 4px solid;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255); \">\u524d\u8a00<\/h2>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u6211\u4eec\u5728\u8fdb\u884c\u8f6f\u4ef6\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u521a\u5f00\u59cb\u7684\u65f6\u5019\u56e0\u4e3a\u65e0\u6cd5\u4f30\u91cf\u7cfb\u7edf\u540e\u671f\u7684\u8bbf\u95ee\u91cf\u548c\u5e76\u53d1\u91cf\uff0c\u6240\u4ee5\u4e00\u5f00\u59cb\u4f1a\u91c7\u7528\u5355\u4f53\u67b6\u6784\uff0c\u540e\u671f\u5982\u679c\u7f51\u7ad9\u6d41\u91cf\u53d8\u5927\uff0c&nbsp;\u5e76\u53d1\u91cf\u53d8\u5927\uff0c\u90a3\u4e48\u5c31\u53ef\u80fd\u4f1a\u5c06\u67b6\u6784\u6269\u5c55\u4e3a\u5fae\u670d\u52a1\u67b6\u6784\uff0c\u5404\u4e2a\u5fae\u670d\u52a1\u5bf9\u5e94\u4e00\u4e2a\u6570\u636e\u5e93\uff0c\u4e0d\u8fc7\u8fd9\u6837\u7684\u6210\u672c\u5c31\u6709\u70b9\u5927\u4e86\uff0c\u53ef\u80fd\u53ea\u662f\u6709\u4e9b\u6a21\u5757\u7528\u7684\u4eba\u6bd4\u8f83\u591a\uff0c&nbsp;\u6709\u4e9b\u6a21\u5757\u6ca1\u4ec0\u4e48\u4eba\u7528\uff0c\u5982\u679c\u90fd\u8fdb\u884c\u670d\u52a1\u62c6\u5206\uff0c\u5176\u5b9e\u4e5f\u6ca1\u90a3\u4e2a\u5fc5\u8981\uff0c\u5982\u679c\u6709\u4e9b\u6a21\u5757\u7528\u7684\u4eba\u6bd4\u8f83\u591a\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u91c7\u7528\u8bfb\u5199\u5206\u79bb\u6765\u51cf\u8f7b\u538b\u529b\uff0c\u8fd9\u6837\u7684\u8bdd\uff0c&nbsp;\u53ef\u4ee5\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u63d0\u5347\u7cfb\u7edf\u7684\u7528\u6237\u4f53\u9a8c\uff0c\u4e0d\u8fc7\u8fd9\u53ea\u662f\u5728\u6570\u636e\u5e93\u7684I\/O\u4e0a\u9762\u505a\u65b9\u6848\uff0c\u5982\u679c\u7cfb\u7edf\u7684\u538b\u529b\u5f88\u5927\uff0c\u90a3\u4e48\u80af\u5b9a\u8981\u505a\u8d1f\u8f7d\u5747\u8861\uff0c\u6211\u4eec\u4eca\u5929\u5c31\u5148\u8bf4&nbsp;\u5b9e\u73b0\u6570\u636e\u5e93\u7684\u8bfb\u5199\u5206\u79bb\u3002\u6211\u4eec\u8981\u5728\u4ee3\u7801\u5c42\u9762\u5b9e\u73b0\u6570\u636e\u5e93\u7684\u8bfb\u5199\u5206\u79bb\uff0c\u90a3\u4e48\u6838\u5fc3\u5c31\u662f\u6570\u636e\u6e90\u7684\u5207\u6362\uff0c\u672c\u6587\u57fa\u4e8eAOP\u6765\u5b9e\u73b0\u6570\u636e\u6e90\u7684\u5207\u6362\u3002<\/p>\n<h2 style=\" box-sizing: border-box;padding-left: 10px;margin-top: 30px;margin-bottom: 30px;color: rgb(19, 92, 224); font-size: 20px;border-left: 4px solid;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255); \">\u5de5\u7a0b\u7ed3\u6784<\/h2>\n<pre style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 15px;overflow: auto; line-height: 1.75;background: rgb(50, 41, 49);color: rgb(185, 181, 184);text-align: start; \"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 12px;overflow: auto; line-height: 1.75;word-break: normal;border-radius: 2px;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;padding: 15px 12px;display: block; \"><span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2514\u2500com<\/span><br  \/>    <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2514\u2500steak<\/span><br  \/>        <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2514\u2500transaction<\/span><br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">TransactionDemoApplication.java<\/span><br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u251c\u2500datasource<\/span><br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">DatasourceChooser.java<\/span><br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">DatasourceConfiguration.java<\/span><br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">DatasourceContext.java<\/span><br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">DatasourceScope.java<\/span><br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">DynamicDatasourceAspect.java<\/span><br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>  <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2514\u2500properties<\/span><br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>          <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">DynamicDatasourceProperties.java<\/span><br  \/>            <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\u2502<\/span>          <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">MainDatasourceProperties.java<\/span>         <br  \/><\/code><\/pre>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u5728\u4e0b\u9762\u7684\u5b9e\u73b0\u4e2d\uff0c\u6211\u4eec\u4e00\u4e2a\u6709\u4e09\u4e2a\u6570\u636e\u6e90\uff0c\u5176\u4e2d\u6709\u4e00\u4e2a\u662f\u9ed8\u8ba4\u7684\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\u5177\u4f53\u7684\u6570\u636e\u6e90\uff0c\u90a3\u4e48\u5c31\u4f7f\u7528\u9ed8\u8ba4\u7684\uff0c\u6211\u4eec\u662f\u57fa\u4e8e\u7533\u660e\u5f0f\u7684\u65b9\u5f0f\u6765\u5207\u6362&nbsp;\u6570\u636e\u6e90\uff0c\u53ea\u9700\u8981\u5728\u5177\u4f53\u7684\u63a5\u53e3\u4e0a\u52a0\u4e0a\u6ce8\u89e3\u4fbf\u80fd\u5b9e\u73b0\u6570\u636e\u6e90\u7684\u5207\u6362\u3002<\/p>\n<h2 style=\" box-sizing: border-box;padding-left: 10px;margin-top: 30px;margin-bottom: 30px;color: rgb(19, 92, 224); font-size: 20px;border-left: 4px solid;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255); \">\u7f16\u7801\u5b9e\u73b0<\/h2>\n<h3 style=\"box-sizing: border-box;padding-top: 30px;padding-bottom: 30px;color: rgb(19, 92, 224);font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">yml\u6587\u4ef6<\/h3>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u4e3b\u6570\u636e\u6e90\u76f4\u63a5\u4f7f\u7528spring\u7684\u914d\u7f6e\uff0c\u5176\u4ed6\u6570\u636e\u6e90\u91c7\u7528\u81ea\u5b9a\u4e49\u7684\u65b9\u5f0f\uff0c\u8fd9\u91cc\u91c7\u7528\u4e00\u4e2amap\u7ed3\u6784\u6765\u5b9a\u4e49\uff0c\u65b9\u4fbf\u8fdb\u884c\u89e3\u6790\uff0c\u53ef\u4ee5\u5728yml\u6587\u4ef6\u91cc\u8fdb\u884c\u6dfb\u52a0\u591a\u4e2a\uff0c\u5728\u4ee3\u7801&nbsp;\u903b\u8f91\u5c42\u9762\u4e0d\u7528\u6539\u52a8\u3002<\/p>\n<pre style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 15px;overflow: auto; line-height: 1.75;background: rgb(50, 41, 49);color: rgb(185, 181, 184);text-align: start; \"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 12px;overflow: auto; line-height: 1.75;word-break: normal;border-radius: 2px;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;padding: 15px 12px;display: block; \"><span style=\"box-sizing: border-box;\">spring:<\/span><br  \/>  <span style=\"box-sizing: border-box;\">datasource:<\/span><br  \/>    <span style=\"box-sizing: border-box;\">type:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">com.alibaba.druid.pool.DruidDataSource<\/span><br  \/>    <span style=\"box-sizing: border-box;\">druid:<\/span><br  \/>      <span style=\"box-sizing: border-box;\">username:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">root<\/span><br  \/>      <span style=\"box-sizing: border-box;\">password:<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">123456<\/span><br  \/>      <span style=\"box-sizing: border-box;\">url:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">jdbc:mysql:\/\/127.0.0.1:3306\/db?useUnicode=true&amp;characterEncoding=UTF-8&amp;useSSL=false&amp;serverTimezone=UTC<\/span><br  \/>      <span style=\"box-sizing: border-box;\">driver-class-name:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">com.mysql.cj.jdbc.Driver<\/span><br  \/><br  \/><span style=\"box-sizing: border-box;\">dynamic:<\/span><br  \/>  <span style=\"box-sizing: border-box;\">datasource:<\/span> {<br  \/>    <span style=\"box-sizing: border-box;\">slave1:<\/span> {<br  \/>      <span style=\"box-sizing: border-box;\">username:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">'root'<\/span>,<br  \/>      <span style=\"box-sizing: border-box;\">password:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">'123456'<\/span>,<br  \/>      <span style=\"box-sizing: border-box;\">url:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">'jdbc:mysql:\/\/127.0.0.1:3306\/db?useUnicode=true&amp;characterEncoding=UTF-8&amp;useSSL=false&amp;serverTimezone=UTC'<\/span>,<br  \/>      <span style=\"box-sizing: border-box;\">driver-class-name:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">'com.mysql.cj.jdbc.Driver'<\/span><br  \/>    },<br  \/>    <span style=\"box-sizing: border-box;\">slave2:<\/span> {<br  \/>      <span style=\"box-sizing: border-box;\">username:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">'root'<\/span>,<br  \/>      <span style=\"box-sizing: border-box;\">password:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">'123456'<\/span>,<br  \/>      <span style=\"box-sizing: border-box;\">url:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">'jdbc:mysql:\/\/127.0.0.1:3306\/db?useUnicode=true&amp;characterEncoding=UTF-8&amp;useSSL=false&amp;serverTimezone=UTC'<\/span>,<br  \/>      <span style=\"box-sizing: border-box;\">driver-class-name:<\/span> <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">'com.mysql.cj.jdbc.Driver'<\/span><br  \/>    }<br  \/>  }<br  \/><\/code><\/pre>\n<h3 style=\"box-sizing: border-box;padding-top: 30px;padding-bottom: 30px;color: rgb(19, 92, 224);font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u4e3b\u6570\u636e\u6e90MainDatasourceProperties<\/h3>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u5bf9\u4e8e\u4e3b\u6570\u636e\u6e90\uff0c\u6211\u4eec\u5355\u72ec\u62ff\u51fa\u6765\u653e\u5728\u4e00\u4e2a\u7c7b\u91cc\u9762\uff0c\u4e0d\u8fc7\u5176\u5b9e\u4e5f\u53ef\u4ee5\u653e\u5230dynamic\u91cc\u9762\uff0c\u53ea\u662f\u9700\u8981\u505a\u4e00\u5b9a\u7684\u5904\u7406\uff0c\u6211\u4eec\u5c31\u7b80\u5355\u7684\u653e\u51e0\u4e2a\u8fde\u63a5\u5c5e\u6027\u3002<\/p>\n<pre style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 15px;overflow: auto; line-height: 1.75;background: rgb(50, 41, 49);color: rgb(185, 181, 184);text-align: start; \"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 12px;overflow: auto; line-height: 1.75;word-break: normal;border-radius: 2px;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;padding: 15px 12px;display: block; \"><span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/**<br  \/> * <span style=\"box-sizing: border-box;\">@author<\/span> \u5218\u724c<br  \/> * <span style=\"box-sizing: border-box;\">@date<\/span> 2022\/3\/220:14<br  \/> *\/<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Component<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@ConfigurationProperties(prefix = \"spring.datasource.druid\")<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Data<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">class<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 204, 89);\">MainDatasourceProperties<\/span> <\/span>{<br  \/>    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">private<\/span> String username;<br  \/>    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">private<\/span> String password;<br  \/>    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">private<\/span> String url;<br  \/>    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">private<\/span> String driverClassName;<br  \/>}<br  \/><\/code><\/pre>\n<h3 style=\"box-sizing: border-box;padding-top: 30px;padding-bottom: 30px;color: rgb(19, 92, 224);font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u5176\u4ed6\u6570\u636e\u6e90DynamicDatasourceProperties<\/h3>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u5176\u4ed6\u6570\u636e\u6e90\u4f7f\u7528\u4e00\u4e2aMap\u6765\u63a5\u53d7yml\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u6e90\u914d\u7f6e<\/p>\n<pre style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 15px;overflow: auto; line-height: 1.75;background: rgb(50, 41, 49);color: rgb(185, 181, 184);text-align: start; \"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 12px;overflow: auto; line-height: 1.75;word-break: normal;border-radius: 2px;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;padding: 15px 12px;display: block; \"><span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/**<br  \/> * <span style=\"box-sizing: border-box;\">@author<\/span> \u5218\u724c<br  \/> * <span style=\"box-sizing: border-box;\">@date<\/span> 2022\/3\/213:47<br  \/> *\/<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Component<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@ConfigurationProperties(prefix = \"dynamic\")<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Data<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">class<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 204, 89);\">DynamicDatasourceProperties<\/span> <\/span>{<br  \/>    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">private<\/span> Map&lt;String,Map&lt;String,String&gt;&gt; datasource;<br  \/>}<br  \/><\/code><\/pre>\n<h3 style=\"box-sizing: border-box;padding-top: 30px;padding-bottom: 30px;color: rgb(19, 92, 224);font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u6570\u636e\u6e90\u914d\u7f6e\u7c7bDatasourceConfiguration<\/h3>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u914d\u7f6e\u7c7b\u4e2d\u4e3b\u8981\u5bf9DataSource\u8fdb\u884c\u914d\u7f6e\uff0c\u4e3b\u6570\u636e\u6e90\u6211\u4eec\u6309\u7167\u6b63\u5e38\u7684bean\u6765\u5b9a\u4e49\u8fde\u63a5\u5c5e\u6027\uff0c\u800c\u5176\u4ed6\u6570\u636e\u6570\u636e\u6e90\u5219\u4f7f\u7528\u53cd\u5c04\u7684\u65b9\u5f0f\u6765\u8fdb\u884c\u8fde\u63a5\u5c5e\u6027\u7684&nbsp;\u914d\u7f6e\uff0c\u56e0\u4e3a\u4e3b\u6570\u636e\u6e90\u4e00\u822c\u662f\u4e0d\u4f1a\u53d8\u52a8\u7684\uff0c\u4f46\u662f\u5176\u4ed6\u6570\u636e\u6e90\u53ef\u80fd\u4f1a\u53d1\u751f\u53d8\u52a8\uff0c\u53ef\u80fd\u4f1a\u6dfb\u52a0\uff0c\u8fd9\u65f6\u5019\u5982\u679c\u901a\u8fc7\u786c\u7f16\u7801\u53d6\u914d\u7f6e\uff0c\u90a3\u4e48\u6bcf\u589e\u52a0\u4e00\u4e2a\u6570\u636e\u6e90\uff0c\u5c31\u9700\u8981&nbsp;\u589e\u52a0\u4e00\u4e2a\u914d\u7f6e\uff0c\u663e\u7136\u4e0d\u592a\u884c\uff0c\u6240\u4ee5\u5c31\u4f7f\u7528\u53cd\u5c04\u6765\u8fdb\u884c\u8d4b\u503c\u3002<\/p>\n<pre style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 15px;overflow: auto; line-height: 1.75;background: rgb(50, 41, 49);color: rgb(185, 181, 184);text-align: start; \"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 12px;overflow: auto; line-height: 1.75;word-break: normal;border-radius: 2px;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;padding: 15px 12px;display: block; \"><span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/**<br  \/> * <span style=\"box-sizing: border-box;\">@author<\/span> \u5218\u724c<br  \/> * <span style=\"box-sizing: border-box;\">@date<\/span> 2022\/3\/111:34<br  \/> *\/<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Configuration<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@AllArgsConstructor<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">class<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 204, 89);\">DatasourceConfiguration<\/span> <\/span>{<br  \/><br  \/>    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">final<\/span> MainDatasourceProperties mainDatasourceProperties;<br  \/>    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">final<\/span> DynamicDatasourceProperties dynamicDatasourceProperties;<br  \/><br  \/>    <span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Bean<\/span><br  \/>    <span style=\"box-sizing: border-box;color: rgb(18, 144, 191);\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> DataSource <span style=\"box-sizing: border-box;\">datasource<\/span><span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">()<\/span><\/span>{<br  \/>        Map&lt;Object,Object&gt; datasourceMap = <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">new<\/span> HashMap&lt;&gt;();<br  \/>        DatasourceChooser datasourceChooser = <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">new<\/span> DatasourceChooser();<br  \/>        <span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/**<br  \/>         * main database<br  \/>         *\/<\/span><br  \/>        DruidDataSource mainDataSource = <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">new<\/span> DruidDataSource();<br  \/>        mainDataSource.setUsername(mainDatasourceProperties.getUsername());<br  \/>        mainDataSource.setPassword(mainDatasourceProperties.getPassword());<br  \/>        mainDataSource.setUrl(mainDatasourceProperties.getUrl());<br  \/>        mainDataSource.setDriverClassName(mainDatasourceProperties.getDriverClassName());<br  \/>        datasourceMap.put(<span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\"main\"<\/span>,mainDataSource);<br  \/>        <span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/**<br  \/>         * other database<br  \/>         *\/<\/span><br  \/>        Map&lt;String, Map&lt;String, String&gt;&gt; sourceMap = dynamicDatasourceProperties.getDatasource();<br  \/>        sourceMap.forEach((datasourceName,datasourceMaps) -&gt; {<br  \/>            DruidDataSource dataSource = <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">new<\/span> DruidDataSource();<br  \/>            datasourceMaps.forEach((K,V) -&gt; {<br  \/>                String setField = <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\"set\"<\/span> + K.substring(<span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">0<\/span>, <span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">1<\/span>).toUpperCase() + K.substring(<span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">1<\/span>);<br  \/>                <span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/\/\u8f6c\u6362yml\u6587\u4ef6\u4e2d\u5e26\u6709-\u7b26\u53f7\u7684\u5c5e\u6027<\/span><br  \/>                String[] strings = setField.split(<span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\"\"<\/span>);<br  \/>                StringBuilder newStr = <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">new<\/span> StringBuilder();<br  \/>                <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">for<\/span> (<span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">int<\/span> i = <span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">0<\/span>; i &lt; strings.length; i++) {<br  \/>                    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">if<\/span> (strings[i].equals(<span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\"-\"<\/span>)) strings[i + <span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">1<\/span>] = strings[i + <span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">1<\/span>].toUpperCase();<br  \/>                    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">if<\/span> (!strings[i].equals(<span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\"-\"<\/span>)) newStr.append(strings[i]);<br  \/>                }<br  \/>                <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">try<\/span> {<br  \/>                    DruidDataSource.class.getMethod(newStr.toString(),String.class).invoke(dataSource,V);<br  \/>                } <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">catch<\/span> (Exception e) {<br  \/>                    e.printStackTrace();<br  \/>                }<br  \/>            });<br  \/>            datasourceMap.put(datasourceName,dataSource);<br  \/>        });<br  \/>        <span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/\/\u8bbe\u7f6e\u76ee\u6807\u6570\u636e\u6e90<\/span><br  \/>        datasourceChooser.setTargetDataSources(datasourceMap);<br  \/>        <span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/\/\u8bbe\u7f6e\u9ed8\u8ba4\u6570\u636e\u6e90<\/span><br  \/>        datasourceChooser.setDefaultTargetDataSource(mainDataSource);<br  \/>        <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">return<\/span> datasourceChooser;<br  \/>    }<br  \/>}<br  \/><\/code><\/pre>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u4e0a\u9762\u4f7f\u7528\u6570\u636e\u6e90\u914d\u7f6e\u7c7b\u4e2d\u4f7f\u7528\u53cd\u5c04\u5bf9\u5176\u4ed6\u6570\u636e\u6e90\u8fdb\u884c\u8fde\u63a5\u5c5e\u6027\u7684\u8bbe\u7f6e\uff0c\u7136\u540e\u8bbe\u7f6e\u76ee\u6807\u6570\u636e\u6e90\u548c\u9ed8\u8ba4\u6570\u636e\u6e90\uff0c\u91cc\u9762\u6709\u4e00\u4e2a<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">DatasourceChooser<\/code>\u3002<\/p>\n<h3 style=\"box-sizing: border-box;padding-top: 30px;padding-bottom: 30px;color: rgb(19, 92, 224);font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">DatasourceChooser<\/h3>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">DatasourceChooser<\/code>\u7ee7\u627f\u81ea<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">AbstractRoutingDataSource<\/code>\uff0c<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">AbstractRoutingDataSource<\/code>\u53ef\u4ee5\u5b9e\u73b0\u6570\u636e\u6e90\u7684\u5207\u6362\uff0c\u5b83\u91cc\u9762\u7684&nbsp;<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">determineCurrentLookupKey()<\/code>\u65b9\u6cd5\u9700\u8981\u6211\u4eec\u8fd4\u56de\u4e00\u4e2a\u6570\u636e\u6e90\u7684\u540d\u79f0\uff0c\u5b83\u4f1a\u81ea\u52a8\u7ed9\u6211\u4eec\u5339\u914d\u4e0a\u6570\u636e\u6e90\u3002<\/p>\n<pre style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 15px;overflow: auto; line-height: 1.75;background: rgb(50, 41, 49);color: rgb(185, 181, 184);text-align: start; \"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 12px;overflow: auto; line-height: 1.75;word-break: normal;border-radius: 2px;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;padding: 15px 12px;display: block; \"><span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/**<br  \/> * <span style=\"box-sizing: border-box;\">@author<\/span> \u5218\u724c<br  \/> * <span style=\"box-sizing: border-box;\">@date<\/span> 2022\/3\/112:21<br  \/> *\/<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">class<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 204, 89);\">DatasourceChooser<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">extends<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 204, 89);\">AbstractRoutingDataSource<\/span> <\/span>{<br  \/>    <span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Override<\/span><br  \/>    <span style=\"box-sizing: border-box;color: rgb(18, 144, 191);\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">protected<\/span> Object <span style=\"box-sizing: border-box;\">determineCurrentLookupKey<\/span><span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">()<\/span> <\/span>{<br  \/>        <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">return<\/span> DatasourceContext.getDatasource();<br  \/>    }<br  \/>}<br  \/><\/code><\/pre>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u5982\u4e0b\u662f<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">AbstractRoutingDataSource<\/code>\u7684\u90e8\u5206\u6e90\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\u6570\u636e\u6e90\u662f\u4e00\u4e2aMap\u7ed3\u6784\uff0c\u53ef\u4ee5\u901a\u8fc7\u6570\u636e\u6e90\u540d\u79f0\u67e5\u627e\u5230\u5bf9\u5e94\u7684\u6570\u636e\u6e90\u3002<\/p>\n<pre style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 15px;overflow: auto; line-height: 1.75;background: rgb(50, 41, 49);color: rgb(185, 181, 184);text-align: start; \"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 12px;overflow: auto; line-height: 1.75;word-break: normal;border-radius: 2px;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;padding: 15px 12px;display: block; \"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">package<\/span> org.springframework.jdbc.datasource.lookup;<br  \/><br  \/><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">abstract<\/span> <span style=\"box-sizing: border-box;\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">class<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 204, 89);\">AbstractRoutingDataSource<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">extends<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 204, 89);\">AbstractDataSource<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">implements<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 204, 89);\">InitializingBean<\/span> <\/span>{<br  \/>    <span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Nullable<\/span><br  \/>    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">private<\/span> Map&lt;Object, DataSource&gt; resolvedDataSources;<br  \/>    <span style=\"box-sizing: border-box;color: rgb(18, 144, 191);\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;\">AbstractRoutingDataSource<\/span><span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">()<\/span> <\/span>{<br  \/>    }<br  \/>    <span style=\"box-sizing: border-box;color: rgb(18, 144, 191);\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">protected<\/span> DataSource <span style=\"box-sizing: border-box;\">determineTargetDataSource<\/span><span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">()<\/span> <\/span>{<br  \/>        Object lookupKey = <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">this<\/span>.determineCurrentLookupKey();<br  \/>        DataSource dataSource = (DataSource)<span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">this<\/span>.resolvedDataSources.get(lookupKey);<br  \/>    }<br  \/><br  \/>    <span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Nullable<\/span><br  \/>    <span style=\"box-sizing: border-box;color: rgb(18, 144, 191);\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">protected<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">abstract<\/span> Object <span style=\"box-sizing: border-box;\">determineCurrentLookupKey<\/span><span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">()<\/span><\/span>;<br  \/>}<br  \/><\/code><\/pre>\n<h3 style=\"box-sizing: border-box;padding-top: 30px;padding-bottom: 30px;color: rgb(19, 92, 224);font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">DatasourceContext<\/h3>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;\"><span style=\"background-color: rgb(255, 255, 255);\"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">DatasourceContext<\/code>\u5185\u90e8\u662f\u4e00\u4e2a<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">ThreadLocal<\/code>\uff0c\u4e3b\u8981\u662f\u7528\u6765\u5b58\u50a8\u6bcf\u4e00\u4e2a\u7ebf\u7a0b\u7684\u6570\u636e\u6e90\u540d\u79f0\u548c\u83b7\u53d6\u6570\u636e\u6e90\u540d\u79f0\uff0c\u800c\u6570\u636e\u6e90\u7684\u540d\u79f0\u6211\u4eec<\/span>\u901a<span style=\"background-color: rgb(255, 255, 255);\">\u8fc7AOP\u5207\u9762\u6765\u83b7\u53d6\u3002<\/span><\/p>\n<pre style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 15px;overflow: auto; line-height: 1.75;background: rgb(50, 41, 49);color: rgb(185, 181, 184);text-align: start; \"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 12px;overflow: auto; line-height: 1.75;word-break: normal;border-radius: 2px;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;padding: 15px 12px;display: block; \"><span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/**<br  \/> * <span style=\"box-sizing: border-box;\">@author<\/span> \u5218\u724c<br  \/> * <span style=\"box-sizing: border-box;\">@date<\/span> 2022\/3\/112:22<br  \/> *\/<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">class<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 204, 89);\">DatasourceContext<\/span> <\/span>{<br  \/>    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">private<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">static<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">final<\/span> ThreadLocal&lt;String&gt; threadLocal = <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">new<\/span> ThreadLocal&lt;&gt;();<br  \/>    <span style=\"box-sizing: border-box;color: rgb(18, 144, 191);\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">static<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">void<\/span> <span style=\"box-sizing: border-box;\">setDatasource<\/span><span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">(String key)<\/span><\/span>{<br  \/>        threadLocal.set(key);<br  \/>    }<br  \/>    <span style=\"box-sizing: border-box;color: rgb(18, 144, 191);\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">static<\/span> String <span style=\"box-sizing: border-box;\">getDatasource<\/span><span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">()<\/span><\/span>{<br  \/>        <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">return<\/span> threadLocal.get();<br  \/>    }<br  \/>}<br  \/><\/code><\/pre>\n<h3 style=\"box-sizing: border-box;padding-top: 30px;padding-bottom: 30px;color: rgb(19, 92, 224);font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u6570\u636e\u6e90\u6ce8\u89e3DatasourceScope<\/h3>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">DatasourceScope<\/code>\u6807\u51c6\u5728\u65b9\u6cd5\u4e0a\u9762\uff0c\u901a\u8fc7<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">scope<\/code>\u6765\u6307\u5b9a\u6570\u636e\u6e90\uff0c\u4e0d\u6307\u5b9a\u9ed8\u8ba4\u4e3a\u4e3b\u6570\u636e\u6e90<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">main<\/code>\u3002<\/p>\n<pre style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 15px;overflow: auto; line-height: 1.75;background: rgb(50, 41, 49);color: rgb(185, 181, 184);text-align: start; \"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 12px;overflow: auto; line-height: 1.75;word-break: normal;border-radius: 2px;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;padding: 15px 12px;display: block; \"><span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/**<br  \/> * <span style=\"box-sizing: border-box;\">@author<\/span> \u5218\u724c<br  \/> * <span style=\"box-sizing: border-box;\">@date<\/span> 2022\/3\/111:22<br  \/> *\/<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Target({ElementType.METHOD})<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Retention(RetentionPolicy.RUNTIME)<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Documented<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@interface<\/span> DatasourceScope {<br  \/>    <span style=\"box-sizing: border-box;color: rgb(18, 144, 191);\">String <span style=\"box-sizing: border-box;\">scope<\/span><span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">()<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">default<\/span> \"main\"<\/span>;<br  \/>}<br  \/><\/code><\/pre>\n<h3 style=\"box-sizing: border-box;padding-top: 30px;padding-bottom: 30px;color: rgb(19, 92, 224);font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u6570\u636e\u6e90\u5207\u9762DynamicDatasourceAspect<\/h3>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u6211\u4eec\u5728\u8bbf\u95ee\u6bcf\u4e00\u4e2a\u5e26\u6709<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">DatasourceScope<\/code>\u6ce8\u89e3\u7684\u65b9\u6cd5\u65f6\uff0c\u90fd\u4f1a\u7ecf\u8fc7\u6570\u636e\u6e90\u5207\u9762<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">DynamicDatasourceAspect<\/code>\uff0c\u83b7\u53d6\u5230\u6ce8\u89e3\u4e0a\u9762\u7684&nbsp;<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">scope<\/code>\u7684\u503c\u540e\uff0c\u901a\u8fc7<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">DatasourceContext<\/code>\u8bbe\u7f6e\u6570\u636e\u6e90\u540d\u79f0\uff0c\u4fbf\u53ef\u5b9e\u73b0\u5bf9\u6570\u636e\u6e90\u7684\u5207\u6362\u3002<\/p>\n<pre style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 15px;overflow: auto; line-height: 1.75;background: rgb(50, 41, 49);color: rgb(185, 181, 184);text-align: start; \"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 12px;overflow: auto; line-height: 1.75;word-break: normal;border-radius: 2px;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;padding: 15px 12px;display: block; \"><span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/**<br  \/> * <span style=\"box-sizing: border-box;\">@author<\/span> \u5218\u724c<br  \/> * <span style=\"box-sizing: border-box;\">@date<\/span> 2022\/3\/111:34<br  \/> *\/<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Aspect<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Component<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">class<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 204, 89);\">DynamicDatasourceAspect<\/span> <\/span>{<br  \/><br  \/>    <span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Pointcut(\"@annotation(dataSourceScope)\")<\/span><br  \/>    <span style=\"box-sizing: border-box;color: rgb(18, 144, 191);\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">void<\/span> <span style=\"box-sizing: border-box;\">dynamicPointcut<\/span><span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">(DatasourceScope dataSourceScope)<\/span><\/span>{}<br  \/><br  \/>    <span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Around(value = \"dynamicPointcut(dataSourceScope)\", argNames = \"joinPoint,dataSourceScope\")<\/span><br  \/>    <span style=\"box-sizing: border-box;color: rgb(18, 144, 191);\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> Object <span style=\"box-sizing: border-box;\">dynamicAround<\/span><span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">(ProceedingJoinPoint joinPoint , DatasourceScope dataSourceScope)<\/span> <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">throws<\/span> Throwable <\/span>{<br  \/>        String scope = dataSourceScope.scope();<br  \/>        DatasourceContext.setDatasource(scope);<br  \/>        <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">return<\/span> joinPoint.proceed();<br  \/>    }<br  \/>}<br  \/><\/code><\/pre>\n<h2 style=\" box-sizing: border-box;padding-left: 10px;margin-top: 30px;margin-bottom: 30px;color: rgb(19, 92, 224); font-size: 20px;border-left: 4px solid;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255); \">\u4f7f\u7528<\/h2>\n<p style=\"box-sizing: border-box;color: rgb(89, 89, 89);font-size: 15px;line-height: 2;font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;background-color: rgb(255, 255, 255);\">\u53ea\u9700\u8981\u5728\u5177\u4f53\u7684\u65b9\u6cd5\u4e0a\u9762\u6807\u6ce8\u6570\u636e\u6e90\u6ce8\u89e3<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">@DatasourceScope<\/code>\uff0c\u5e76\u6307\u5b9a<code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 0.87em;overflow: auto; line-height: 1.75;word-break: break-word;border-radius: 2px;background-color: rgb(255, 245, 245);color: rgb(255, 80, 44);padding: 0.065em 0.4em; \">scope<\/code>\u7684\u503c\uff0c\u4fbf\u53ef\u5b9e\u73b0\u5207\u6362\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u90a3\u4e48\u5c31\u4f7f\u7528\u4e3b\u6570\u636e\u6e90\u3002<\/p>\n<pre style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 15px;overflow: auto; line-height: 1.75;background: rgb(50, 41, 49);color: rgb(185, 181, 184);text-align: start; \"><code style=\" box-sizing: border-box;font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size: 12px;overflow: auto; line-height: 1.75;word-break: normal;border-radius: 2px;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;padding: 15px 12px;display: block; \"><span style=\"box-sizing: border-box;color: rgb(152, 148, 152);\">\/**<br  \/> * <span style=\"box-sizing: border-box;\">@author<\/span> \u5218\u724c<br  \/> * <span style=\"box-sizing: border-box;\">@date<\/span> 2022\/3\/19:49<br  \/> *\/<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@Service<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@AllArgsConstructor<\/span><br  \/><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> <span style=\"box-sizing: border-box;\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">class<\/span> <span style=\"box-sizing: border-box;color: rgb(253, 204, 89);\">OrderService<\/span> <\/span>{<br  \/>    <br  \/>    <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">private<\/span> JdbcTemplate jdbcTemplate;<br  \/>    <br  \/>    <span style=\"box-sizing: border-box;color: rgb(20, 155, 147);\">@DatasourceScope(scope = \"slave1\")<\/span><br  \/>    <span style=\"box-sizing: border-box;color: rgb(18, 144, 191);\"><span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">public<\/span> R <span style=\"box-sizing: border-box;\">saveOrder<\/span><span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">(Integer userId , Integer commodityId)<\/span><\/span>{<br  \/>        String sql = <span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\"INSERT INTO `order`(user_id,commodity_id) VALUES(\"<\/span>+userId+<span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\",\"<\/span>+commodityId+<span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\")\"<\/span>;<br  \/>        jdbcTemplate.execute(sql);<br  \/>        <span style=\"box-sizing: border-box;color: rgb(200, 94, 124);\">return<\/span> R.builder().code(<span style=\"box-sizing: border-box;color: rgb(253, 139, 25);\">200<\/span>).msg(<span style=\"box-sizing: border-box;color: rgb(143, 193, 62);\">\"save order success\"<\/span>).build();<br  \/>    }<br  \/>}<br  \/><\/code><\/pre>\n<blockquote style=\"box-sizing: border-box;background: rgb(255, 249, 249);margin-top: 2em;margin-bottom: 2em;padding: 2px 20px;border-left-width: 4px;border-left-color: rgb(178, 174, 197);color: rgb(89, 89, 89);font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: start;white-space: normal;\">\n<p style=\"box-sizing: border-box;color: rgb(102, 102, 102);line-height: 2;\">\u5173\u4e8e\u591a\u6570\u636e\u6e90\u7684\u5207\u6362\uff0c\u5c31\u5206\u4eab\u5230\u8fd9\u91cc\uff0c\u611f\u8c22\u4f60\u7684\u89c2\u770b\uff0c\u4e0b\u671f\u89c1<\/p>\n<\/blockquote>\n<p><br  \/><\/p>\n<blockquote>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7:                 \u5218\u724c              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u7801\u519c\u5728\u56e7\u9014 \u6bcf\u5f53\u6674\u7a7a\u4e07\u91cc\u7684\u65f6\u5019\uff0c\u5929\u7a7a\u4f9d\u7136\u662f\u6e5b\u84dd\u7684\uff0c\u591c\u91cc\u6211\u8fd8\u662f\u4f1a\u4ef0\u671b\u8fd9\u96be\u5f97\u7684\u661f\u7a7a\u4fef\u77b0\u504c\u5927\u7684\u57ce\u5e02\uff0c\u4e07\u5bb6\u706f\u706b\u4e2d\u5374\u6ca1\u6709\u4e00\u76cf\u706f\u662f\u4e3a\u6211\u4eae\u7740\u7684\u3002 &#8230;<\/p>\n","protected":false},"author":2,"featured_media":721,"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-722","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\/20230528015642322-150x150.jpeg","content_first_image":null,"post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015642322-300x128.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015642322-1024x436.jpeg","post_frist_image":null,"post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015642322-300x128.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015642322-1024x436.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015642322.jpeg","post_all_images":[],"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":653,"next_post_id":535,"next_post_title":"Controller\u5c42\u4ee3\u7801\u5c31\u8be5\u8fd9\u4e48\u5199\uff0c\u7b80\u6d01\u53c8\u4f18\u96c5\uff01","previous_post_id":583,"previous_post_title":"Springboot \u52a8\u6001\u914d\u7f6e\u53ca\u4e00\u952e\u6253\u5305\u90e8\u7f72","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/722","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=722"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/722\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/721"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}