{"id":201107,"date":"2020-11-24T20:42:25","date_gmt":"2020-11-24T12:42:25","guid":{"rendered":"http:\/\/4563.org\/?p=201107"},"modified":"2020-11-24T20:42:25","modified_gmt":"2020-11-24T12:42:25","slug":"%e6%88%91%e7%9a%84%e5%bc%80%e6%ba%90%e7%bb%8f%e5%8e%86%ef%bc%9a%e4%b8%ba%e4%ba%86%e6%96%b9%e4%be%bf%e5%a4%84%e7%90%86%e4%b8%89%e6%96%b9-http-%e6%8e%a5%e5%8f%a3%e8%80%8c%e5%86%99%e7%9a%84-java","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=201107","title":{"rendered":"\u6211\u7684\u5f00\u6e90\u7ecf\u5386\uff1a\u4e3a\u4e86\u65b9\u4fbf\u5904\u7406\u4e09\u65b9 HTTP \u63a5\u53e3\u800c\u5199\u7684 Java \u6846\u67b6"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6211\u7684\u5f00\u6e90\u7ecf\u5386\uff1a\u4e3a\u4e86\u65b9\u4fbf\u5904\u7406\u4e09\u65b9 HTTP \u63a5\u53e3\u800c\u5199\u7684 Java \u6846\u67b6               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : DtFlys <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h3>\u7f18\u8d77<\/h3>\n<p>\u6211\u4ee5\u524d\u516c\u53f8\u9700\u8981\u5728 Java \u540e\u53f0\u8c03\u7528\u8bb8\u591a\u7b2c\u4e09\u65b9 HTTP \u63a5\u53e3\uff0c\u6bd4\u5982\u5fae\u4fe1\u652f\u4ed8\u3001\u53cb\u76df\u7b49\u7b49\u7b2c\u4e09\u65b9\u5e73\u53f0\u3002 \u516c\u53f8\u5185\u90e8\u8fd8\u6709\u5f88\u591a\u670d\u52a1\u662f\u7528\u4e16\u754c\u6700\u597d\u8bed\u8a00\u5199\u7684\uff0c\u63a5\u53e3\u81ea\u7136\u4e5f\u53ea\u80fd\u901a\u8fc7 HTTP \u63a5\u53e3\u6765\u8c03\u7528\u3002\u4e8e\u662f\u65e5\u79ef\u6708\u7d2f\u4e0b\u6765\uff0c\u5728 Java \u4ee3\u7801\u4e2d\u5c31\u6709\u8bb8\u8bb8\u591a\u591a\u5404\u5f0f\u5404\u6837\u7684 HTTP \u8c03\u7528\u63a5\u53e3\uff0c\u800c\u4e14\u8c03\u7528\u65b9\u5f0f\u4e5f\u4e0d\u7edf\u4e00\uff0c\u6709 HttpClient \u5199\u7684\u3001\u6709 OkHttp \u5199\u7684\u3001\u6709\u81ea\u5df1\u5305\u88c5\u7684\uff0c\u5149\u516c\u53f8\u5185\u90e8\u4e0d\u540c\u4eba\u5305\u88c5\u7684 HTTP \u5de5\u5177\u7c7b\u5c31\u6709\u4e24\u4e09\u79cd\u3002 \u800c\u4e14 url \u57fa\u672c\u5199\u6b7b\u5728\u4ee3\u7801\u4e2d\uff0c\u5f88\u96be\u7ef4\u62a4\uff0c\u4e0d\u540c\u63a5\u53e3\u53c8\u6709\u4e0d\u540c\u7684\u53c2\u6570\u4f20\u8f93\u65b9\u5f0f\uff0c\u6709 GET \u3001\u6709 POST\uff0c\u6709 JSON \u4f20\u8f93\u7684\u3001\u6709 XML \u4f20\u8f93\u7684\u3002 \u5f53\u6709\u4e00\u4e2a\u63a5\u53e3\u9700\u8981\u4fee\u6539\uff0c\u5b8c\u4e86\uff0c\u5149\u627e\u5230\u4ee3\u7801\u5728\u4ec0\u4e48\u5730\u65b9\u5c31\u8981\u82b1\u534a\u5929\u65f6\u95f4\u3002<\/p>\n<h3>\u8d77\u6b65<\/h3>\n<p>\u4e8e\u662f\uff0c\u6211\u5c31\u60f3\u80fd\u4e0d\u80fd\u5c06\u6240\u6709 Java \u7684 HTTP \u63a5\u53e3\u5c01\u88c5\u6210\u98ce\u683c\u7edf\u4e00\u7684\u63a5\u53e3\uff0c\u4f7f\u5f97 http \u4fe1\u606f\u548c\u4e1a\u52a1\u4ee3\u7801\u89e3\u8026\uff0c\u8ba9\u63a5\u53e3\u8c03\u7528\u65b9\u538b\u6839\u5c31\u9700\u8981\u8981\u5173\u7cfb HTTP \u8bf7\u6c42\u53d1\u9001\u7684\u7ec6\u8282\uff0c\u5173\u6ce8\u63a5\u53e3\u672c\u8eab\u8981\u505a\u4ec0\u4e48\u4e8b\u5373\u53ef\u3002\u5c31\u50cf Dubbo \u90a3\u79cd RPC \u63a5\u53e3\u4e00\u6837\uff0c\u5bf9\u8bf7\u6c42\u8c03\u7528\u65b9\u6765\u8bf4\u53ea\u662f\u8c03\u7528\u4e00\u4e2a\u666e\u901a\u7684 Java \u63a5\u53e3\u5bf9\u8c61\u7684\u666e\u901a Java \u65b9\u6cd5\uff0c\u4f20\u5165\u9700\u8981 Java \u57fa\u672c\u7c7b\u578b\u6216\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\u503c\uff0c\u8fd4\u56de\u4e00\u4e2a Java \u5bf9\u8c61\u4f5c\u4e3a\u8fd4\u56de\u503c\uff0c\u6574\u4e2a\u8fc7\u7a0b\u611f\u53d7\u4e0d\u5230 HTTP \u7684\u5b58\u5728\u3002 \u6240\u6709 HTTP \u76f8\u5173\u7684\u4fe1\u606f\u90fd\u901a\u8fc7\u6ce8\u89e3\u6807\u6ce8\u5728\u63a5\u53e3\u548c\u65b9\u6cd5\u4e0a\uff0c\u5982\u540c JPA \u90a3\u6837\uff0c\u5f53\u8981\u7ef4\u62a4 HTTP \u63a5\u53e3\u7684\u65f6\u5019\u4e00\u76ee\u4e86\u7136\u3002<\/p>\n<p>\u7136\u540e\uff0c\u6211\u4e8e 2015 \u5e74\u5f00\u59cb\u7f16\u5199Forest\uff0c\u5728\u90a3\u4e2a\u65f6\u5019\u4e0d\u77e5\u6709 Feign\uff0c\u65e0\u8bba Retrofit (^\u25bd^ )\u3002\u6240\u8c13\u65e0\u77e5\u8005\u65e0\u754f\uff0c\u6ca1\u591a\u4e45\u5c31\u5b8c\u6210\u4e86\u7b2c\u4e00\u7248\u672c\uff0c\u5e76\u5728\u516c\u53f8\u5185\u90e8\u987a\u5229\u63a8\u5e7f\u5f00\u6765\uff0c\u5c3d\u7ba1\u65e9\u8d77\u7248\u672c\u6709\u5404\u79cd\u5404\u6837 Bug\uff0c\u4f46\u5927\u5bb6\u53cd\u5e94\u8fd8\u662f\u4e00\u4e2a\u5b57\uff1a\u9999\u3002<\/p>\n<p>Gitee \u5730\u5740\uff1ahttps:\/\/gitee.com\/dt_flys\/forest<\/p>\n<h3>\u6311\u6218<\/h3>\n<p>\u8fd9\u4e5f\u76f4\u63a5\u4fc3\u4f7f\u6211\u5728 2016 \u5e74\u5c06\u5176\u5f00\u6e90\uff0c\u5728 Gitee \u4e0a\u4e09\u5929\u5185\u6da8\u5230\u4e86 100 star\uff0c\u4f46\u5f53\u65f6\u6211\u5e76\u4e0d\u61c2\u5f97\u5982\u4f55\u63a8\u5e7f\u548c\u7ef4\u62a4\u4e00\u4e2a\u5f00\u6e90\u793e\u533a\uff0c\u6240\u4ee5 star \u6570\u7684\u589e\u957f\u4e5f\u5c31\u540e\u7ee7\u65e0\u529b\u4e86\u3002<\/p>\n<p>\u800c\u4e14\u6e10\u6e10\u5f97\u77e5\u6709 Feign \u548c Retrofit \u7684\u5b58\u5728\uff0c\u5bf9\u6211\u4e5f\u662f\u4e2a\u4e0d\u5c0f\u6253\u51fb\uff0c\u6bd5\u7adf\u4eba\u5bb6\u5df2\u7ecf\u5341\u5206\u6210\u719f\u4e86\uff0c\u6211\u4e5f\u5c31\u653e\u5f03\u4e86 Forest \u4e00\u6bb5\u65f6\u95f4\u3002<\/p>\n<h3>\u8f6c\u673a<\/h3>\n<p>\u4e0d\u8fc7\uff0c\u5728\u8fd9\u6bb5\u65f6\u95f4\u5df2\u7ecf\u5728\u516c\u53f8\u7684\u751f\u4ea7\u73af\u5883\u4f7f\u7528 Forest\uff0c\u5728\u540c\u4e8b\u7684\u53cd\u9988\u4e0b\u4e0d\u65ad\u5730\u505a\u4e9b\u4fee\u4fee\u8865\u8865\uff08\u6bd5\u7adf\u6211\u5199\u7684\uff0c\u5c31\u8981\u8d1f\u8d23\u5230\u5e95\uff09\uff0c\u4f46\u4e5f\u6b63\u56e0\u4e3a\u5982\u6b64 Forest \u6e10\u6e10\u6210\u719f\u548c\u7a33\u5b9a\u4e0b\u6765\u3002\u540c\u65f6\uff0c\u5728\u540c\u4e8b\u7684\u9f13\u52b1\u4e0b\uff0c\u6211\u4e5f\u60f3\u5230\u4e86 Forest \u5c5e\u4e8e\u81ea\u5df1\u7684\u53d1\u5c55\u8def\u7ebf\uff1a\u66ff\u6362 HttpClient \u548c OkHttp\uff0c\u4e0e Retrofit \u548c Feign \u505a\u5dee\u5f02\u5316\uff0c\u76f8\u6bd4 Retrofit \u4e0e SpringBoot \u96c6\u6210\u66f4\u597d\uff0c\u4e0e Feign \u76f8\u6bd4\u66f4\u9488\u5bf9\u4e8e\u7b2c\u4e09\u65b9 HTTP \u63a5\u53e3\uff0c\u540c\u65f6\u6709\u5b8c\u5584\u7684\u4e2d\u6587\u6587\u6863\u3001\u4e2d\u6587\u793e\u533a\uff0c\u65b9\u4fbf\u56fd\u5185\u5f00\u53d1\u8005\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<h3>\u73b0\u72b6<\/h3>\n<p>\u81f3\u6b64\uff0c\u6211\u4e8e\u4eca\u5e74\u4e0b\u534a\u5e74\u91cd\u65b0\u62fe\u8d77 Forest\uff0c\u4e0d\u65ad\u8fed\u4ee3\uff0c\u81ea\u4eca\u5e74 7 \u6708\u4efd\u4ee5\u6765\u5f97\u5230\u4e86 500+ star\uff0c\u867d\u7136\u4e0e\u4e0a\u5343 star \u7684\u77e5\u540d\u9879\u76ee\u6765\u6bd4\u7b97\u4e0d\u4e86\u4ec0\u4e48\uff0c\u4f46\u5bf9\u6211\u4e5f\u662f\u6781\u5927\u7684\u9f13\u52b1\uff0c\u4e5f\u8ba9\u6211\u6162\u6162\u7406\u89e3\u5e94\u8be5\u5982\u4f55\u53bb\u505a\u597d\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\uff0c\u4ee5\u540e\u6709\u673a\u4f1a\u4f1a\u5199\u4e00\u4e9b\u5f00\u6e90\u7684\u5fc3\u5f97\uff08\u505a\u5f00\u6e90\u7684\u611f\u53d7\uff09\u3002<\/p>\n<p>\u54c8\u54c8\uff0c\u8fd9\u662f\u6211\u7b2c\u4e00\u6b21\u5728 V2EX \u53d1\u5e16\uff0c\u671b\u5927\u5bb6\u8f7b\u55b7~~<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>13<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4227724\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : bryan31 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5927\u4f6c\u52a0\u6cb9\uff0c\u5f00\u6e90\u4e0d\u5bb9\u6613\uff0c\u652f\u6301\u4e00\u6ce2                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227725\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zoharSoul <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u548c Retrofit \u611f\u89c9\u633a\u50cf\u7684. \u652f\u6301\u534f\u7a0b\u4e86\u5417?                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227726\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : DtFlys <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zoharSoul \u786e\u5b9e\u548c Retrofit \u6bd4\u8f83\u50cf\uff0c\u56e0\u4e3a\u662f\u7c7b\u4f3c\u7684\u601d\u8def\u8bbe\u8ba1\u7684\u3002Forest \u6ca1\u6709\u57fa\u4e8e Kotlin \u6765\u505a\uff0c\u6240\u4ee5\u6ca1\u6709\u652f\u6301\u534f\u7a0b\uff0c\u4f46\u652f\u6301\u56de\u8c03\u51fd\u6570\u65b9\u5f0f\u7684\u5f02\u6b65\u548c Java Future \u65b9\u5f0f\u7684\u5f02\u6b65\u8bf7\u6c42\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227727\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kylix <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9876\u4e00\u4e0b\u5927\u4f6c\uff0c\u5e0c\u671b\u80fd\u4e00\u76f4\u575a\u6301\u4e0b\u53bb\uff01                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227728\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : VHacker1989 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9020\u8fd9\u79cd\u8f6e\u5b50\u9664\u975e\u4f60\u6709\u6bd4 retrofit\uff0cfeign \u6709\u72ec\u7279\u4f18\u52bf\uff0c\u4e0d\u7136\u5f88\u96be\u63a8\u5e7f\uff0c\u66f4\u4e0d\u7528\u8bf4\u5728\u751f\u4ea7\u73af\u5883\u7528                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227729\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : DtFlys <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @kylix \u611f\u8c22\u652f\u6301                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227730\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : DtFlys <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @VHacker1989 \u7684\u786e\uff0c\u8fd9\u4e5f\u662f\u6211\u5728\u601d\u8003\u548c\u6478\u7d22\u7684\u5730\u65b9\u3002\u73b0\u5728\u5df2\u7ecf\u6709\u4e00\u4e9b\u4f01\u4e1a\u5728\u751f\u4ea7\u7528\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227731\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : itcastcn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5927\u4f6c\u5389\u5bb3\uff0c\u652f\u6301\u5f00\u6e90                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227732\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : IfEles <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f00\u6e90\u4e0d\u6613\uff0c\u652f\u6301\u4e00\u6ce2                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227733\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : herofire <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u52a0\u6cb9\uff0c\u5f00\u6e90\u7cbe\u795e\u503c\u5f97\u652f\u6301                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227734\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zouzou0208 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3b\u8981\u5728 GitHub \u7ef4\u62a4\u662f\u4e0d\u597d\u4e00\u4e9b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227735\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : DtFlys <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @herofire \u8c22\u8c22\u652f\u6301                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4227736\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : DtFlys <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zouzou0208 \u786e\u5b9e\u8f83\u4e3a\u4e13\u6ce8\u4e8e Gitee\uff0cGithub \u6bd4\u8f83\u5ffd\u89c6                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u7684\u5f00\u6e90\u7ecf\u5386\uff1a\u4e3a\u4e86\u65b9\u4fbf\u5904\u7406\u4e09\u65b9 H&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/201107"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201107"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/201107\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201107"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}