{"id":61233,"date":"2024-10-13T09:32:18","date_gmt":"2024-10-13T01:32:18","guid":{"rendered":"https:\/\/server.hk\/cnblog\/61233\/"},"modified":"2024-10-13T09:32:19","modified_gmt":"2024-10-13T01:32:19","slug":"dubbo%e6%9e%b6%e6%a7%8b%e8%88%87%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e9%85%8d%e5%90%88%ef%bc%9a%e6%a7%8b%e5%bb%ba%e5%bc%b7%e5%a4%a7%e7%9a%84%e5%88%86%e4%bd%88%e5%bc%8f%e6%87%89%e7%94%a8%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/61233\/","title":{"rendered":"Dubbo\u67b6\u69cb\u8207\u6578\u64da\u5eab\u7684\u914d\u5408\uff1a\u69cb\u5efa\u5f37\u5927\u7684\u5206\u4f48\u5f0f\u61c9\u7528\u7a0b\u5e8f (dubbo\u67b6\u69cb \u6578\u64da\u5eab)"},"content":{"rendered":"<h1 id=\"dubbo%e6%9e%b6%e6%a7%8b%e8%88%87%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e9%85%8d%e5%90%88%ef%bc%9a%e6%a7%8b%e5%bb%ba%e5%bc%b7%e5%a4%a7%e7%9a%84%e5%88%86%e4%bd%88%e5%bc%8f%e6%87%89%e7%94%a8%e7%a8%8b-KOVvysgXYS\">Dubbo\u67b6\u69cb\u8207\u6578\u64da\u5eab\u7684\u914d\u5408\uff1a\u69cb\u5efa\u5f37\u5927\u7684\u5206\u4f48\u5f0f\u61c9\u7528\u7a0b\u5e8f<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u8edf\u4ef6\u958b\u767c\u4e2d\uff0c\u5206\u4f48\u5f0f\u61c9\u7528\u7a0b\u5e8f\u5df2\u6210\u70ba\u4e00\u7a2e\u4e3b\u6d41\u67b6\u69cb\u3002\u96a8\u8457\u696d\u52d9\u9700\u6c42\u7684\u589e\u9577\uff0c\u958b\u767c\u8005\u9700\u8981\u4e00\u7a2e\u9748\u6d3b\u4e14\u53ef\u64f4\u5c55\u7684\u89e3\u6c7a\u65b9\u6848\u4f86\u8655\u7406\u5927\u91cf\u7684\u8acb\u6c42\u548c\u6578\u64da\u3002Dubbo\u4f5c\u70ba\u4e00\u500b\u9ad8\u6027\u80fd\u7684Java RPC\u6846\u67b6\uff0c\u63d0\u4f9b\u4e86\u826f\u597d\u7684\u89e3\u6c7a\u65b9\u6848\u4f86\u69cb\u5efa\u5206\u4f48\u5f0f\u7cfb\u7d71\u3002\u672c\u6587\u5c07\u63a2\u8a0eDubbo\u67b6\u69cb\u8207\u6578\u64da\u5eab\u7684\u914d\u5408\uff0c\u5e6b\u52a9\u958b\u767c\u8005\u69cb\u5efa\u5f37\u5927\u7684\u5206\u4f48\u5f0f\u61c9\u7528\u7a0b\u5e8f\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afdubbo%ef%bc%9f-KOVvysgXYS\">\u4ec0\u9ebc\u662fDubbo\uff1f<\/h2>\n<p>Dubbo\u662f\u4e00\u500b\u958b\u6e90\u7684\u9ad8\u6027\u80fdRPC\u6846\u67b6\uff0c\u6700\u521d\u7531\u963f\u91cc\u5df4\u5df4\u958b\u767c\u3002\u5b83\u652f\u6301\u591a\u7a2e\u5354\u8b70\u548c\u5e8f\u5217\u5316\u65b9\u5f0f\uff0c\u4e26\u63d0\u4f9b\u4e86\u670d\u52d9\u6cbb\u7406\u3001\u8ca0\u8f09\u5747\u8861\u3001\u5bb9\u932f\u7b49\u529f\u80fd\u3002Dubbo\u7684\u6838\u5fc3\u601d\u60f3\u662f\u5c07\u670d\u52d9\u62c6\u5206\u70ba\u591a\u500b\u5fae\u670d\u52d9\uff0c\u9019\u6a23\u53ef\u4ee5\u63d0\u9ad8\u7cfb\u7d71\u7684\u53ef\u7dad\u8b77\u6027\u548c\u53ef\u64f4\u5c55\u6027\u3002<\/p>\n<h2 id=\"dubbo%e6%9e%b6%e6%a7%8b%e7%9a%84%e5%9f%ba%e6%9c%ac%e7%b5%84%e4%bb%b6-KOVvysgXYS\">Dubbo\u67b6\u69cb\u7684\u57fa\u672c\u7d44\u4ef6<\/h2>\n<ul>\n<li><strong>Provider\uff1a<\/strong>\u63d0\u4f9b\u670d\u52d9\u7684\u670d\u52d9\u5668\uff0c\u8ca0\u8cac\u8655\u7406\u5ba2\u6236\u7aef\u7684\u8acb\u6c42\u3002<\/li>\n<li><strong>Consumer\uff1a<\/strong>\u8abf\u7528\u670d\u52d9\u7684\u5ba2\u6236\u7aef\uff0c\u5411Provider\u767c\u9001\u8acb\u6c42\u3002<\/li>\n<li><strong>Registry\uff1a<\/strong>\u670d\u52d9\u8a3b\u518a\u4e2d\u5fc3\uff0c\u8ca0\u8cac\u7ba1\u7406\u670d\u52d9\u7684\u8a3b\u518a\u548c\u767c\u73fe\u3002<\/li>\n<li><strong>Monitor\uff1a<\/strong>\u76e3\u63a7\u7cfb\u7d71\u6027\u80fd\u548c\u670d\u52d9\u72c0\u614b\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e5%9c%a8dubbo%e6%9e%b6%e6%a7%8b%e4%b8%ad%e7%9a%84%e8%a7%92%e8%89%b2-KOVvysgXYS\">\u6578\u64da\u5eab\u5728Dubbo\u67b6\u69cb\u4e2d\u7684\u89d2\u8272<\/h2>\n<p>\u5728\u5206\u4f48\u5f0f\u61c9\u7528\u7a0b\u5e8f\u4e2d\uff0c\u6578\u64da\u5eab\u662f\u5b58\u5132\u548c\u7ba1\u7406\u6578\u64da\u7684\u6838\u5fc3\u7d44\u4ef6\u3002Dubbo\u67b6\u69cb\u901a\u5e38\u9700\u8981\u8207\u6578\u64da\u5eab\u9032\u884c\u4ea4\u4e92\uff0c\u4ee5\u4fbf\u5b58\u53d6\u548c\u64cd\u4f5c\u6578\u64da\u3002\u4ee5\u4e0b\u662f\u6578\u64da\u5eab\u5728Dubbo\u67b6\u69cb\u4e2d\u7684\u5e7e\u500b\u91cd\u8981\u89d2\u8272\uff1a<\/p>\n<ul>\n<li><strong>\u6578\u64da\u6301\u4e45\u5316\uff1a<\/strong>\u5c07\u61c9\u7528\u7a0b\u5e8f\u7684\u6578\u64da\u6301\u4e45\u5316\u5230\u6578\u64da\u5eab\u4e2d\uff0c\u4ee5\u4fbf\u5728\u7cfb\u7d71\u91cd\u555f\u6216\u6545\u969c\u5f8c\u80fd\u5920\u6062\u5fa9\u3002<\/li>\n<li><strong>\u6578\u64da\u5171\u4eab\uff1a<\/strong>\u5728\u591a\u500b\u5fae\u670d\u52d9\u4e4b\u9593\u5171\u4eab\u6578\u64da\uff0c\u78ba\u4fdd\u6578\u64da\u7684\u4e00\u81f4\u6027\u548c\u5b8c\u6574\u6027\u3002<\/li>\n<li><strong>\u67e5\u8a62\u6027\u80fd\uff1a<\/strong>\u901a\u904e\u512a\u5316\u6578\u64da\u5eab\u67e5\u8a62\uff0c\u63d0\u9ad8\u61c9\u7528\u7a0b\u5e8f\u7684\u97ff\u61c9\u901f\u5ea6\u3002<\/li>\n<\/ul>\n<h2 id=\"dubbo%e8%88%87%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e6%95%b4%e5%90%88-KOVvysgXYS\">Dubbo\u8207\u6578\u64da\u5eab\u7684\u6574\u5408<\/h2>\n<p>\u5728Dubbo\u67b6\u69cb\u4e2d\uff0c\u6574\u5408\u6578\u64da\u5eab\u901a\u5e38\u6d89\u53ca\u4ee5\u4e0b\u5e7e\u500b\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e9%85%8d%e7%bd%ae%e6%95%b8%e6%93%9a%e6%ba%90-KOVvysgXYS\">1. \u914d\u7f6e\u6578\u64da\u6e90<\/h3>\n<pre><code>\nspring.datasource.url=jdbc:mysql:\/\/localhost:3306\/mydb\nspring.datasource.username=root\nspring.datasource.password=yourpassword\n<\/code><\/pre>\n<p>\u5728Spring\u914d\u7f6e\u6587\u4ef6\u4e2d\u8a2d\u7f6e\u6578\u64da\u6e90\uff0c\u78ba\u4fddDubbo\u670d\u52d9\u80fd\u5920\u9023\u63a5\u5230\u6578\u64da\u5eab\u3002<\/p>\n<h3 id=\"2-%e5%89%b5%e5%bb%ba%e6%95%b8%e6%93%9a%e8%a8%aa%e5%95%8f%e5%b1%a4-KOVvysgXYS\">2. \u5275\u5efa\u6578\u64da\u8a2a\u554f\u5c64<\/h3>\n<p>\u4f7f\u7528ORM\u6846\u67b6\uff08\u5982MyBatis\u6216Hibernate\uff09\u4f86\u5275\u5efa\u6578\u64da\u8a2a\u554f\u5c64\uff0c\u9019\u6a23\u53ef\u4ee5\u7c21\u5316\u6578\u64da\u5eab\u64cd\u4f5c\u3002<\/p>\n<pre><code>\npublic interface UserMapper {\n    User selectUserById(int id);\n}\n<\/code><\/pre>\n<h3 id=\"3-%e5%9c%a8dubbo%e6%9c%8d%e5%8b%99%e4%b8%ad%e8%aa%bf%e7%94%a8%e6%95%b8%e6%93%9a%e8%a8%aa%e5%95%8f%e5%b1%a4-KOVvysgXYS\">3. \u5728Dubbo\u670d\u52d9\u4e2d\u8abf\u7528\u6578\u64da\u8a2a\u554f\u5c64<\/h3>\n<pre><code>\n@Service\npublic class UserServiceImpl implements UserService {\n    @Autowired\n    private UserMapper userMapper;\n\n    @Override\n    public User getUserById(int id) {\n        return userMapper.selectUserById(id);\n    }\n}\n<\/code><\/pre>\n<p>\u9019\u6a23\uff0c\u7576\u5ba2\u6236\u7aef\u8abf\u7528UserService\u6642\uff0c\u670d\u52d9\u5c07\u901a\u904eUserMapper\u8a2a\u554f\u6578\u64da\u5eab\uff0c\u7372\u53d6\u6240\u9700\u7684\u6578\u64da\u3002<\/p>\n<h2 id=\"%e6%80%a7%e8%83%bd%e5%84%aa%e5%8c%96%e5%bb%ba%e8%ad%b0-KOVvysgXYS\">\u6027\u80fd\u512a\u5316\u5efa\u8b70<\/h2>\n<p>\u5728Dubbo\u67b6\u69cb\u4e2d\uff0c\u6578\u64da\u5eab\u7684\u6027\u80fd\u5c0d\u6574\u9ad4\u7cfb\u7d71\u7684\u97ff\u61c9\u901f\u5ea6\u81f3\u95dc\u91cd\u8981\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u512a\u5316\u5efa\u8b70\uff1a<\/p>\n<ul>\n<li><strong>\u4f7f\u7528\u9023\u63a5\u6c60\uff1a<\/strong>\u901a\u904e\u4f7f\u7528\u6578\u64da\u5eab\u9023\u63a5\u6c60\u4f86\u6e1b\u5c11\u9023\u63a5\u7684\u958b\u92b7\u3002<\/li>\n<li><strong>\u67e5\u8a62\u512a\u5316\uff1a<\/strong>\u5c0d\u983b\u7e41\u4f7f\u7528\u7684\u67e5\u8a62\u9032\u884c\u512a\u5316\uff0c\u4f7f\u7528\u7d22\u5f15\u4f86\u63d0\u9ad8\u67e5\u8a62\u6548\u7387\u3002<\/li>\n<li><strong>\u7de9\u5b58\u6a5f\u5236\uff1a<\/strong>\u4f7f\u7528\u7de9\u5b58\u6280\u8853\uff08\u5982Redis\uff09\u4f86\u6e1b\u5c11\u5c0d\u6578\u64da\u5eab\u7684\u76f4\u63a5\u8a2a\u554f\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-KOVvysgXYS\">\u7e3d\u7d50<\/h2>\n<p>Dubbo\u67b6\u69cb\u8207\u6578\u64da\u5eab\u7684\u6709\u6548\u914d\u5408\u662f\u69cb\u5efa\u5f37\u5927\u5206\u4f48\u5f0f\u61c9\u7528\u7a0b\u5e8f\u7684\u95dc\u9375\u3002\u901a\u904e\u5408\u7406\u7684\u8a2d\u8a08\u548c\u512a\u5316\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u5be6\u73fe\u9ad8\u6548\u7684\u6578\u64da\u8655\u7406\u548c\u670d\u52d9\u8abf\u7528\u3002\u7121\u8ad6\u662f\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u5eab\uff0c\u9084\u662f\u512a\u5316\u67e5\u8a62\u6027\u80fd\uff0c\u9019\u4e9b\u90fd\u662f\u63d0\u5347\u7cfb\u7d71\u6574\u9ad4\u6027\u80fd\u7684\u91cd\u8981\u56e0\u7d20\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u90e8\u7f72\u60a8\u7684Dubbo\u61c9\u7528\u7a0b\u5e8f\uff0cServer.HK\u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\u4ee5\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22Dubbo\u67b6\u69cb\u8207\u6578\u64da\u5eab\u7684\u5b8c\u7f8e\u7d50\u5408\uff0c\u6253\u9020\u9ad8\u6548\u80fd\u7684\u5206\u4f48\u5f0f\u61c9\u7528\u7a0b\u5e8f\uff0c\u63d0\u5347\u7cfb\u7d71\u7a69\u5b9a\u6027\u8207\u64f4\u5c55\u6027\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-61233","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=61233"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61233\/revisions"}],"predecessor-version":[{"id":61234,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61233\/revisions\/61234"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=61233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=61233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=61233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}