{"id":2677,"date":"2018-04-20T21:06:34","date_gmt":"2018-04-20T13:06:34","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2677"},"modified":"2018-04-20T21:06:34","modified_gmt":"2018-04-20T13:06:34","slug":"%e8%9a%82%e8%9a%81-sofaboot-%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2677","title":{"rendered":"\u8682\u8681 SOFABoot \u6559\u7a0b"},"content":{"rendered":"<p>\n\tSOFABoot \u662f\u8682\u8681\u91d1\u670d\u5f00\u6e90\u7684\u57fa\u4e8e Spring Boot \u7684\u7814\u53d1\u6846\u67b6\uff0c\u5b83\u5728 Spring Boot \u7684\u57fa\u7840\u4e0a\uff0c\u63d0\u4f9b\u4e86\u8bf8\u5982 Readiness Check\uff0c\u7c7b\u9694\u79bb\uff0c\u65e5\u5fd7\u7a7a\u95f4\u9694\u79bb\u7b49\u7b49\u80fd\u529b\u3002\u5728\u589e\u5f3a\u4e86 Spring Boot \u7684\u540c\u65f6\uff0cSOFABoot \u63d0\u4f9b\u4e86\u8ba9\u7528\u6237\u53ef\u4ee5\u5728 Spring Boot \u4e2d\u975e\u5e38\u65b9\u4fbf\u5730\u4f7f\u7528 SOFAStack \u76f8\u5173\u4e2d\u95f4\u4ef6\u7684\u80fd\u529b\u3002\n<\/p>\n<h2>\n\t\u4e00\u3001\u80cc\u666f<br \/>\n<\/h2>\n<p>\n\tSpring Boot \u662f\u4e00\u4e2a\u975e\u5e38\u4f18\u79c0\u7684\u5f00\u6e90\u6846\u67b6\uff0c\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u5c31\u6784\u5efa\u51fa\u4e00\u4e2a\u57fa\u4e8e Spring \u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f46\u662f\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u8fd8\u662f\u4f1a\u9047\u5230\u4e00\u4e9b\u95ee\u9898\uff1a\n<\/p>\n<ul>\n<li>\n\t\tSpring Boot \u63d0\u4f9b\u4e86\u4e00\u4e2a\u57fa\u7840\u7684\u5065\u5eb7\u68c0\u67e5\u7684\u80fd\u529b\uff0c\u4e2d\u95f4\u4ef6\u548c\u5e94\u7528\u90fd\u53ef\u4ee5\u6269\u5c55\u6765\u5b9e\u73b0\u81ea\u5df1\u7684\u5065\u5eb7\u68c0\u67e5\u903b\u8f91\u3002\u4f46\u662f Spring Boot \u7684\u5065\u5eb7\u68c0\u67e5\u53ea\u6709 Liveness Check \u7684\u80fd\u529b\uff0c\u7f3a\u5c11 Readiness Check \u7684\u80fd\u529b\uff0c\u8fd9\u6837\u4f1a\u6709\u6bd4\u8f83\u81f4\u547d\u7684\u95ee\u9898\u3002\u5f53\u4e00\u4e2a\u5fae\u670d\u52a1\u5e94\u7528\u542f\u52a8\u7684\u65f6\u5019\uff0c\u5fc5\u987b\u8981\u5148\u4fdd\u8bc1\u542f\u52a8\u540e\u5e94\u7528\u662f\u5065\u5eb7\u7684\uff0c\u624d\u53ef\u4ee5\u5c06\u4e0a\u6e38\u7684\u6d41\u91cf\u653e\u8fdb\u6765\uff08\u6765\u81ea\u4e8e RPC\uff0c\u7f51\u5173\uff0c\u5b9a\u65f6\u4efb\u52a1\u7b49\u7b49\u6d41\u91cf\uff09\uff0c\u5426\u5219\u5c31\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e00\u5b9a\u65f6\u95f4\u5185\u5927\u91cf\u7684\u9519\u8bef\u53d1\u751f\u3002\n\t<\/li>\n<li>\n\t\tSpring Boot \u867d\u7136\u901a\u8fc7\u4f9d\u8d56\u7ba1\u7406\uff08Dependency Management\uff09\u7684\u65b9\u5f0f\u6700\u5927\u7a0b\u5ea6\u7684\u4fdd\u8bc1\u4e86 Spring Boot \u7ba1\u7406\u7684 JAR \u5305\u4e4b\u95f4\u7684\u517c\u5bb9\u6027\uff0c\u4f46\u662f\u4e0d\u53ef\u907f\u514d\u7684\uff0c\u5f53\u5f15\u5165\u4e00\u4e9b\u5176\u4ed6\u7684 JAR \u5305\u7684\u65f6\u5019\uff0c\u8fd8\u662f\u53ef\u80fd\u4f1a\u9047\u5230\u51b2\u7a81\uff0c\u800c\u4e14\u5f88\u591a\u65f6\u5019\u8fd9\u79cd\u51b2\u7a81\u89e3\u51b3\u8d77\u6765\u5e76\u4e0d\u662f\u8fd9\u4e48\u5bb9\u6613\uff0c\u4e00\u4e2a\u4f8b\u5b50\u662f\u5f53\u51b2\u7a81\u7684\u5305\u662f\u5e8f\u5217\u5316\u76f8\u5173\u7684\u7c7b\u5e93\u65f6\uff0c\u6bd4\u5982\u8bf4 Hessian\uff0c\u5982\u679c\u5e94\u7528\u4e2d\u7684\u4e00\u4e2a\u7ec4\u4ef6\u9700\u8981\u4f7f\u7528 Hessian 3\uff0c\u800c\u53e6\u4e00\u4e2a\u5219\u5fc5\u987b\u8981\u4f7f\u7528 Hessian 4\uff0c\u7531\u4e8e Hessian 3 \u548c Hessian 4 \u4e4b\u95f4\u7684\u4e0d\u517c\u5bb9\u6027\uff0c\u5e76\u4e14\u5e8f\u5217\u5316\u8fd8\u6d89\u53ca\u5230\u5fae\u670d\u52a1\u4e2d\u7684\u4e0a\u4e0b\u6e38\u670d\u52a1\uff0c\u8981\u628a Hessian \u7edf\u4e00\u5230\u4e00\u4e2a\u7248\u672c\u7edd\u975e\u6613\u4e8b\u3002\n\t<\/li>\n<li>\n\t\t\u5728\u8d85\u5927\u89c4\u6a21\u5fae\u670d\u52a1\u8fd0\u7ef4\u7684\u573a\u666f\u4e0b\uff0c\u8fd0\u7ef4\u80fd\u529b\u7684\u5e73\u53f0\u5316\u662f\u4e00\u5b9a\u8981\u89e3\u51b3\u7684\u95ee\u9898\uff0c\u800c\u76d1\u63a7\u53c8\u662f\u5176\u4e2d\u975e\u5e38\u4e3b\u8981\u7684\u4e00\u4e2a\u70b9\uff0c\u9488\u5bf9\u4e8e\u65e5\u5fd7\u76d1\u63a7\u8fd9\u79cd\u60c5\u51b5\uff0cSpring Boot \u5e76\u6ca1\u6709\u63d0\u4f9b\u4efb\u4f55\u89e3\u51b3\u65b9\u6848\u3002\u5927\u90e8\u5206\u7684\u5f00\u6e90\u7ec4\u4ef6\uff0c\u5177\u4f53\u8981\u6253\u5370\u54ea\u4e9b\u65e5\u5fd7\uff0c\u6253\u5370\u5230\u4ec0\u4e48\u8def\u5f84\uff0c\u4ec0\u4e48\u6587\u4ef6\u4e0b\u9762\uff0c\u90fd\u662f\u7531\u5e94\u7528\u7684\u4f7f\u7528\u8005\u6765\u51b3\u5b9a\uff0c\u8fd9\u6837\u4f1a\u5bfc\u81f4\u6bcf\u4e00\u4e2a\u5e94\u7528\u7684\u65e5\u5fd7\u914d\u7f6e\u90fd\u5404\u5f0f\u5404\u6837\uff0c\u6bcf\u4e00\u4e2a\u5e94\u7528\u90fd\u9700\u8981\u53bb\u76d1\u63a7\u7cfb\u7edf\u4e2d\u914d\u7f6e\u81ea\u5df1\u5e94\u7528\u7684\u65e5\u5fd7\u76d1\u63a7\uff0c\u5bfc\u81f4\u5173\u952e\u7684\u76d1\u63a7\u7684\u5b9e\u65bd\u6210\u672c\u7279\u522b\u9ad8\u3002\n\t<\/li>\n<\/ul>\n<p>\n\t\u4e3a\u4e86\u89e3\u51b3\u4ee5\u4e0a\u7684\u95ee\u9898\uff0c\u53c8\u56e0\u4e3a SOFAStack \u4e2d\u7684\u8bf8\u591a\u4e2d\u95f4\u4ef6\u672c\u8eab\u5c31\u9700\u8981\u96c6\u6210 Spring Boot\uff0c\u6240\u4ee5\u8682\u8681\u91d1\u670d\u57fa\u4e8e Spring Boot \u5f00\u53d1\u5e76\u5f00\u6e90\u4e86 SOFABoot\uff0c\u6765\u89e3\u51b3\u4ee5\u4e0a\u7684\u95ee\u9898\uff0c\u4e5f\u65b9\u4fbf\u4f7f\u7528\u8005\u5728 Spring Boot \u4e2d\u65b9\u4fbf\u5730\u53bb\u4f7f\u7528 SOFAStack \u4e2d\u95f4\u4ef6\u3002\n<\/p>\n<h2>\n\t\u4e8c\u3001\u529f\u80fd\u7b80\u4ecb<br \/>\n<\/h2>\n<p>\n\t\u4e3a\u4e86\u89e3\u51b3 Spring Boot \u5728\u5b9e\u65bd\u5927\u89c4\u6a21\u5fae\u670d\u52a1\u67b6\u6784\u65f6\u5019\u7684\u95ee\u9898\uff0cSOFABoot \u63d0\u4f9b\u4e86\u4ee5\u4e0b\u7684\u80fd\u529b\uff1a\n<\/p>\n<h3>\n\t2.1 \u589e\u5f3a Spring Boot \u7684\u5065\u5eb7\u68c0\u67e5\u80fd\u529b<br \/>\n<\/h3>\n<p>\n\t\u9488\u5bf9 Spring Boot \u7f3a\u5c11 Readiness Check \u80fd\u529b\u7684\u60c5\u51b5\uff0cSOFABoot \u589e\u52a0\u4e86 Spring Boot \u73b0\u6709\u7684\u5065\u5eb7\u68c0\u67e5\u7684\u80fd\u529b\uff0c\u63d0\u4f9b\u4e86 Readiness Check \u7684\u80fd\u529b\u3002\u5229\u7528 Readiness Check \u7684\u80fd\u529b\uff0cSOFAStack \u4e0b\u5404\u79cd\u4e2d\u95f4\u4ef6\u53ea\u6709\u5728 Readiness Check \u901a\u8fc7\u4e4b\u540e\uff0c\u624d\u5c06\u6d41\u91cf\u5f15\u5165\u5230\u5e94\u7528\u7684\u5b9e\u4f8b\u4e2d\uff0c\u6bd4\u5982 RPC\uff0c\u53ea\u6709\u5728 Readiness Check \u901a\u8fc7\u4e4b\u540e\uff0c\u624d\u4f1a\u5411\u670d\u52a1\u6ce8\u518c\u4e2d\u5fc3\u6ce8\u518c\uff0c\u540e\u9762\u6765\u81ea\u4e0a\u6e38\u5e94\u7528\u7684\u6d41\u91cf\u624d\u4f1a\u8fdb\u5165\u3002\n<\/p>\n<p>\n\t\u9664\u4e86\u4e2d\u95f4\u4ef6\u53ef\u4ee5\u5229\u7528 Readiness Check \u7684\u4e8b\u4ef6\u6765\u63a7\u5236\u6d41\u91cf\u7684\u8fdb\u5165\u4e4b\u5916\uff0cPAAS \u7cfb\u7edf\u4e5f\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee&nbsp;<code>http:\/\/localhost:8080\/health\/readiness<\/code>&nbsp;\u6765\u83b7\u53d6\u5e94\u7528\u7684 Readiness Check \u7684\u72b6\u51b5\uff0c\u7528\u6765\u63a7\u5236\u4f8b\u5982\u8d1f\u8f7d\u5747\u8861\u8bbe\u5907\u7b49\u7b49\u7684\u6d41\u91cf\u3002\n<\/p>\n<h3>\n\t2.2 \u63d0\u4f9b\u7c7b\u9694\u79bb\u7684\u80fd\u529b<br \/>\n<\/h3>\n<p>\n\t\u4e3a\u4e86\u89e3\u51b3 Spring Boot \u4e0b\u7684\u7c7b\u4f9d\u8d56\u51b2\u7a81\u7684\u95ee\u9898\uff0cSOFABoot \u57fa\u4e8e SOFAArk \u63d0\u4f9b\u4e86 Spring Boot \u4e0a\u7684\u7c7b\u9694\u79bb\u7684\u80fd\u529b\uff0c\u5728\u4e00\u4e2a SOFABoot \u7684\u7cfb\u7edf\u4e2d\uff0c\u53ea\u8981\u5f15\u5165 SOFAArk \u76f8\u5173\u7684\u4f9d\u8d56\uff0c\u5c31\u53ef\u4ee5\u5c06 SOFAStack \u7684\u4e2d\u95f4\u4ef6\u76f8\u5173\u7684\u7c7b\u548c\u5e94\u7528\u76f8\u5173\u7684\u7c7b\u7684 ClassLoader \u8fdb\u884c\u9694\u79bb\uff0c\u9632\u6b62\u51fa\u73b0\u7c7b\u51b2\u7a81\u3002\u5f53\u7136\uff0c\u7528\u6237\u4e5f\u53ef\u4ee5\u57fa\u4e8e SOFAArk\uff0c\u5c06\u5176\u4ed6\u7684\u4e2d\u95f4\u4ef6\u3001\u7b2c\u4e09\u65b9\u7684\u4f9d\u8d56\u548c\u5e94\u7528\u7684\u7c7b\u8fdb\u884c\u9694\u79bb\u3002\n<\/p>\n<h3>\n\t2.3 \u65e5\u5fd7\u7a7a\u95f4\u9694\u79bb\u80fd\u529b<br \/>\n<\/h3>\n<p>\n\t\u4e3a\u4e86\u7edf\u4e00\u5927\u89c4\u6a21\u5fae\u670d\u52a1\u573a\u666f\u4e0b\u7684\u4e2d\u95f4\u4ef6\u65e5\u5fd7\u7684\u6253\u5370\uff0cSOFABoot \u63d0\u4f9b\u4e86\u65e5\u5fd7\u7a7a\u95f4\u9694\u79bb\u7684\u80fd\u529b\u7ed9\u5404\u4e2a SOFAStack \u7684\u4e2d\u95f4\u4ef6\uff0c\u5404\u4e2a SOFAStack \u7684\u4e2d\u95f4\u4ef6\u91c7\u7528\u65e5\u5fd7\u7a7a\u95f4\u9694\u79bb\u7684\u80fd\u529b\u4e4b\u540e\uff0c\u81ea\u52a8\u5c31\u4f1a\u5c06\u672c\u8eab\u7684\u65e5\u5fd7\u548c\u5e94\u7528\u7684\u666e\u901a\u65e5\u5fd7\u9694\u79bb\u5f00\u6765\uff0c\u5e76\u4e14\u6253\u5370\u7684\u65e5\u5fd7\u7684\u8def\u5f84\u4e5f\u662f\u76f8\u5bf9\u56fa\u5b9a\uff0c\u975e\u5e38\u65b9\u4fbf\u8fdb\u884c\u7edf\u4e00\u5730\u76d1\u63a7\u3002\n<\/p>\n<h3>\n\t2.4 SOFAStack \u4e2d\u95f4\u4ef6\u7684\u96c6\u6210\u7ba1\u7406<br \/>\n<\/h3>\n<p>\n\t\u57fa\u4e8e Spring Boot \u7684\u81ea\u52a8\u914d\u7f6e\u80fd\u529b\uff0cSOFABoot \u63d0\u4f9b\u4e86 SOFAStack \u4e2d\u95f4\u4ef6\u7edf\u4e00\u6613\u7528\u7684\u7f16\u7a0b\u63a5\u53e3\u4ee5\u53ca Spring Boot \u7684 Starter\uff0c\u65b9\u4fbf\u5728 Spring Boot \u73af\u5883\u4e0b\u4f7f\u7528 SOFAStack \u4e2d\u95f4\u4ef6\uff0c\u6bcf\u4e00\u4e2a SOFAStack \u4e2d\u95f4\u4ef6\u90fd\u662f\u72ec\u7acb\u53ef\u63d2\u62d4\u7684\u7ec4\u4ef6\uff0c\u8282\u7ea6\u5f00\u53d1\u65f6\u95f4\uff0c\u548c\u540e\u671f\u7ef4\u62a4\u7684\u6210\u672c\u3002\n<\/p>\n<p>\n\t\u4e0b\u6ee1\u6211\u4eec\u521b\u5efa\u4e00\u4e2a Spring Boot \u7684\u5de5\u7a0b\uff0c\u5f15\u5165 SOFABoot \u57fa\u7840\u4f9d\u8d56\uff0c\u5e76\u4e14\u5f15\u5165 SOFABoot \u7684\u5065\u5eb7\u68c0\u67e5\u6269\u5c55\u80fd\u529b\uff0c\u6f14\u793a\u5982\u4f55\u5feb\u901f\u4e0a\u624b SOFABoot\u3002\n<\/p>\n<h2>\n\t\u73af\u5883\u51c6\u5907<br \/>\n<\/h2>\n<p>\n\t\u8981\u4f7f\u7528 SOFABoot\uff0c\u9700\u8981\u5148\u51c6\u5907\u597d\u57fa\u7840\u73af\u5883\uff0cSOFABoot \u4f9d\u8d56\u4ee5\u4e0b\u73af\u5883\uff1a\n<\/p>\n<ul>\n<li>\n\t\tJDK7 \u6216 JDK8\n\t<\/li>\n<li>\n\t\t\u9700\u8981\u91c7\u7528 Apache Maven 2.2.5 \u6216\u8005\u4ee5\u4e0a\u7684\u7248\u672c\u6765\u7f16\u8bd1\n\t<\/li>\n<\/ul>\n<h2>\n\t\u521b\u5efa\u5de5\u7a0b<br \/>\n<\/h2>\n<p>\n\tSOFABoot \u662f\u76f4\u63a5\u6784\u5efa\u5728 Spring Boot \u4e4b\u4e0a\uff0c\u56e0\u6b64\u53ef\u4ee5\u4f7f\u7528&nbsp;<a href=\"http:\/\/start.spring.io\/\" rel=\"nofollow\">Spring Boot \u7684\u5de5\u7a0b\u751f\u6210\u5de5\u5177<\/a>&nbsp;\u6765\u751f\u6210\uff0c\u5728\u672c\u6587\u6863\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u6dfb\u52a0\u4e00\u4e2a Web \u7684\u4f9d\u8d56\uff0c\u4ee5\u4fbf\u6700\u540e\u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u6548\u679c\u3002\n<\/p>\n<h2>\n\t\u5f15\u5165 SOFABoot<br \/>\n<\/h2>\n<p>\n\t\u5728\u521b\u5efa\u597d\u4e00\u4e2a Spring Boot \u7684\u5de5\u7a0b\u4e4b\u540e\uff0c\u63a5\u4e0b\u6765\u5c31\u9700\u8981\u5f15\u5165 SOFABoot \u7684\u4f9d\u8d56\uff0c\u9996\u5148\uff0c\u9700\u8981\u5c06\u4e0a\u6587\u4e2d\u751f\u6210\u7684 Spring Boot \u5de5\u7a0b\u7684&nbsp;<code>zip<\/code>&nbsp;\u5305\u89e3\u538b\u540e\uff0c\u4fee\u6539 maven \u9879\u76ee\u7684\u914d\u7f6e\u6587\u4ef6&nbsp;<code>pom.xml<\/code>\uff0c\u5c06\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;parent&gt;\r\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\r\n    &lt;version&gt;${spring.boot.version}&lt;\/version&gt;\r\n    &lt;relativePath\/&gt; \r\n&lt;\/parent&gt;<\/pre>\n<p>\n\t\u66ff\u6362\u4e3a\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;parent&gt;\r\n    &lt;groupId&gt;com.alipay.sofa&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;sofaboot-dependencies&lt;\/artifactId&gt;\r\n    &lt;version&gt;2.3.1&lt;\/version&gt;\r\n&lt;\/parent&gt;<\/pre>\n<p>\n\t\u7136\u540e\uff0c\u6dfb\u52a0\u4e00\u4e2a SOFABoot \u5065\u5eb7\u68c0\u67e5\u6269\u5c55\u80fd\u529b\u7684\u4f9d\u8d56\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;com.alipay.sofa&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;healthcheck-sofa-boot-starter&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>\n\t\u6700\u540e\uff0c\u5728\u5de5\u7a0b\u7684 application.properties \u6587\u4ef6\u4e0b\u6dfb\u52a0\u4e00\u4e2a SOFABoot \u5fc5\u987b\u8981\u4f7f\u7528\u7684\u53c2\u6570\uff0c\u5305\u62ecspring.application.name \u7528\u4e8e\u6807\u793a\u5f53\u524d\u5e94\u7528\u7684\u540d\u79f0\uff1blogging path \u7528\u4e8e\u6307\u5b9a\u65e5\u5fd7\u7684\u8f93\u51fa\u76ee\u5f55\u3002\n<\/p>\n<pre class=\"brush:plain;\">\r\n# Application Name\r\nspring.application.name=SOFABoot Demo\r\n# logging path\r\nlogging.path=.\/logs<\/pre>\n<h2>\n\t\u8fd0\u884c<br \/>\n<\/h2>\n<p>\n\t\u53ef\u4ee5\u5c06\u5de5\u7a0b\u5bfc\u5165\u5230 IDE \u4e2d\u8fd0\u884c\u751f\u6210\u7684\u5de5\u7a0b\u91cc\u9762\u4e2d\u7684&nbsp;<code>main<\/code>&nbsp;\u65b9\u6cd5\uff08\u4e00\u822c\u4e0a\u5728 XXXApplication \u8fd9\u4e2a\u7c7b\u4e2d\uff09\u542f\u52a8\u5e94\u7528\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5728\u8be5\u5de5\u7a0b\u7684\u6839\u76ee\u5f55\u4e0b\u8fd0\u884c&nbsp;<code>mvnw spring-boot:run<\/code>\uff0c\u5c06\u4f1a\u5728\u63a7\u5236\u53f0\u4e2d\u770b\u5230\u542f\u52a8\u6253\u5370\u7684\u65e5\u5fd7\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\n2018-04-05 21:36:26.572  INFO ---- Initializing ProtocolHandler [\"http-nio-8080\"]\r\n2018-04-05 21:36:26.587  INFO ---- Starting ProtocolHandler [http-nio-8080]\r\n2018-04-05 21:36:26.608  INFO ---- Using a shared selector for servlet write\/read\r\n2018-04-05 21:36:26.659  INFO ---- Tomcat started on port(s): 8080 (http)<\/pre>\n<p>\n\t\u53ef\u4ee5\u901a\u8fc7\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165 http:\/\/localhost:8080\/sofaboot\/versions \u6765\u67e5\u770b\u5f53\u524d SOFABoot \u4e2d\u4f7f\u7528 Maven \u63d2\u4ef6\u751f\u6210\u7684\u7248\u672c\u4fe1\u606f\u6c47\u603b\uff0c\u7ed3\u679c\u7c7b\u4f3c\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\n[\r\n\r\n  {\r\n    GroupId: &quot;com.alipay.sofa&quot;,\r\n    Doc-Url: &quot;https:\/\/github.com\/alipay\/sofa-boot&quot;,\r\n    ArtifactId: &quot;infra-sofa-boot-starter&quot;,\r\n    Built-Time: &quot;2018-04-05T20:55:26+0800&quot;,\r\n    Commit-Time: &quot;2018-04-05T20:54:26+0800&quot;,\r\n    Commit-Id: &quot;049bf890bb468aafe6a3e07b77df45c831076996&quot;,\r\n    Version: &quot;2.3.1&quot;\r\n  }\r\n]<\/pre>\n<p>\n\t\u53ef\u4ee5\u901a\u8fc7\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165 http:\/\/localhost:8080\/health\/readiness \u67e5\u770b\u5e94\u7528 Readiness Check \u7684\u72b6\u51b5\uff0c\u7c7b\u4f3c\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\n{\r\n  status: &quot;UP&quot;,\r\n  sofaBootComponentHealthCheckInfo: {\r\n    status: &quot;UP&quot;\r\n  },\r\n  springContextHealthCheckInfo: {\r\n    status: &quot;UP&quot;\r\n  },\r\n  DiskSpace: {\r\n    status: &quot;UP&quot;,\r\n    total: 250140434432,\r\n    free: 22845308928,\r\n    threshold: 10485760\r\n  }\r\n}<\/pre>\n<p>\n\tstatus: &quot;UP&quot; \u8868\u793a\u5e94\u7528 Readiness Check \u5065\u5eb7\u7684\u3002\u53ef\u4ee5\u901a\u8fc7\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165 http:\/\/localhost:8080\/health \u6765\u67e5\u770b\u5e94\u7528\u7684\u8fd0\u884c\u65f6\u5065\u5eb7\u72b6\u6001\uff08\u53ef\u80fd\u4f1a\u968f\u7740\u65f6\u95f4\u53d1\u751f\u53d8\u5316\uff09\u3002\n<\/p>\n<h2>\n\t\u67e5\u770b\u65e5\u5fd7<br \/>\n<\/h2>\n<p>\n\t\u5728\u4e0a\u9762\u7684 application.properties \u91cc\u9762\uff0c\u6211\u4eec\u914d\u7f6e\u7684\u65e5\u5fd7\u6253\u5370\u76ee\u5f55\u662f .\/logs \u5373\u5f53\u524d\u5e94\u7528\u7684\u6839\u76ee\u5f55\uff08\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u5b9e\u8df5\u9700\u8981\u914d\u7f6e\uff09\uff0c\u5728\u5f53\u524d\u5de5\u7a0b\u7684\u6839\u76ee\u5f55\u4e0b\u53ef\u4ee5\u770b\u5230\u7c7b\u4f3c\u5982\u4e0b\u7ed3\u6784\u7684\u65e5\u5fd7\u6587\u4ef6\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\n.\/logs\r\n\u251c\u2500\u2500 health-check\r\n\u2502   \u251c\u2500\u2500 sofaboot-common-default.log\r\n\u2502   \u2514\u2500\u2500 sofaboot-common-error.log\r\n\u251c\u2500\u2500 infra\r\n\u2502   \u251c\u2500\u2500 common-default.log\r\n\u2502   \u2514\u2500\u2500 common-error.log\r\n\u2514\u2500\u2500 spring.log<\/pre>\n<p>\n\t\u5982\u679c\u5e94\u7528\u542f\u52a8\u5931\u8d25\u6216\u8005\u5065\u5eb7\u68c0\u67e5\u8fd4\u56de\u5931\u8d25\uff0c\u53ef\u4ee5\u901a\u8fc7\u76f8\u5e94\u7684\u65e5\u5fd7\u6587\u4ef6\u627e\u5230\u9519\u8bef\u7684\u539f\u56e0\uff0c\u6709\u4e9b\u9700\u8981\u5173\u6ce8 common-error.log \u65e5\u5fd7\u3002\n<\/p>\n<h2>\n\t\u6d4b\u8bd5<br \/>\n<\/h2>\n<p>\n\t\u6211\u4eec\u77e5\u9053\uff0cSpringBoot \u5b98\u65b9\u63d0\u4f9b\u4e86\u548c JUnit4 \u96c6\u6210\u7684&nbsp;<code>SpringRunner<\/code>, \u7528\u4e8e\u96c6\u6210\u6d4b\u8bd5\u7528\u4f8b\u7684\u7f16\u5199\uff1b \u5728 SOFABoot \u4e2d\uff0c\u4f9d\u7136\u53ef\u4ee5\u4f7f\u7528\u539f\u751f\u7684&nbsp;<code>SpringRunner<\/code>\uff0c \u4f46\u662f\u63a8\u8350\u4f7f\u7528 SOFABoot \u81ea\u5e26\u7684&nbsp;<code>SofaBootRunner<\/code>&nbsp;\u4ee5\u53ca&nbsp;<code>SofaJUnit4Runner<\/code>&nbsp;\u7f16\u5199\u96c6\u6210\u6d4b\u8bd5\u548c\u5355\u5143\u6d4b\u8bd5\uff1b\u5e94\u7528\u9700\u8981\u989d\u5916\u5f15\u5165\u5982\u4e0b Starter:\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;com.alipay.sofa&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;test-sofa-boot-starter&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>\n\t\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u9700\u8981\u4f7f\u7528 SOFABoot \u7684\u7c7b\u9694\u79bb\u7684\u80fd\u529b\uff0c\u5219\u5fc5\u987b\u9700\u8981\u5f15\u5165\u4e0a\u8ff0\u7684\u4f9d\u8d56\uff0c\u5e76\u4e14\u4f7f\u7528 SofaBootRunner \u548c SofaJUnit4Runner \u6765\u6d4b\u8bd5\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2677\">\u8682\u8681 SOFABoot \u6559\u7a0b<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>SOFABoot \u662f\u8682\u8681\u91d1\u670d\u5f00\u6e90\u7684\u57fa\u4e8e Spring Boot \u7684\u7814\u53d1\u6846\u67b6\uff0c\u5b83\u5728 Spring Boot \u7684\u57fa [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[991,587,588,919,1350],"class_list":["post-2677","post","type-post","status-publish","format-standard","hentry","category-java","tag-shiro-spring","tag-spring-boot","tag-spring-cloud","tag-spring-io-platform","tag-spring-mvc"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2677"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2677\/revisions"}],"predecessor-version":[{"id":2678,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2677\/revisions\/2678"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}