From d6a98e402e4eeeec3a408f184fe11643d76b6bf3 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期三, 02 七月 2025 13:20:04 +0800
Subject: [PATCH] 1

---
 rpc-server/src/main/java/com/zy/SpringBootRpcServerApplication.java |   17 +
 rpc-server/src/main/resources/application.properties                |   14 
 .gitignore                                                          |   11 
 rpc-server/target/classes/application.properties                    |   18 +
 api/src/main/java/com/zy/entity/User.java                           |   32 ++
 web-server/src/main/resources/application.properties                |   12 
 web-server/src/main/java/com/zy/controller/UserController.java      |   22 +
 .idea/.gitignore                                                    |   10 
 api/pom.xml                                                         |   17 +
 .idea/misc.xml                                                      |    4 
 README.md                                                           |  271 ++++++++++++++++++
 service/pom.xml                                                     |   76 +++++
 web-server/src/main/java/com/zy/SpringBootAplication.java           |   17 +
 web-server/target/classes/application.properties                    |   14 
 rpc-server/pom.xml                                                  |   42 ++
 api/src/main/java/com/zy/service/UserService.java                   |   12 
 service/src/main/java/com/zy/support/UserServiceSupport.java        |   26 +
 LICENSE                                                             |  201 +++++++++++++
 web-server/pom.xml                                                  |   41 ++
 19 files changed, 856 insertions(+), 1 deletions(-)

diff --git a/.gitignore b/.gitignore
index 32858aa..a1c2a23 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,11 @@
+# Compiled class file
 *.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
 
 # Mobile Tools for Java (J2ME)
 .mtj.tmp/
@@ -6,7 +13,11 @@
 # Package Files #
 *.jar
 *.war
+*.nar
 *.ear
+*.zip
+*.tar.gz
+*.rar
 
 # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
 hs_err_pid*
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..7bc07ec
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Environment-dependent path to Maven home directory
+/mavenHomeManager.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..90dee70
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="KubernetesApiProvider">{}</component>
+</project>
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/README.md b/README.md
index 2d98e73..ec4243d 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,273 @@
-## algo-java
+## 浠嬬粛
+
+Dubbo鏄竴娆鹃珮鎬ц兘銆佽交閲忕骇鐨勫紑婧怞ava RPC锛圧emote Procedure
+Call锛岃繙绋嬭繃绋嬭皟鐢級妗嗘灦锛屽畠鎻愪緵浜嗗垎甯冨紡绯荤粺涓湇鍔′箣闂寸殑楂樻晥銆侀�忔槑鍖栫殑鏈嶅姟璋冪敤鏂规銆侱ubbo鏈�鍒濈敱闃块噷宸村反鍏徃寮�鍙戝苟寮�婧愶紝鐜板凡鎴愪负Apache椤剁骇椤圭洰銆�
+
+## 鏋舵瀯婕斿彉
+
+鍦ㄤ簡瑙ubbo涔嬪悗锛屾垜浠鐭ラ亾dubbo鍦ㄥ綋浠婁簰鑱旂綉鏋舵瀯涓湪浠�涔堟牱鐨勪綅缃紝鎴戜滑鍏堟潵鐪嬩竴涓灦鏋勬紨杩涘浘
+
+![image-20240611185459491](img/87db65d9f5a8ff7acba7367a440ef7a5.png)
+
+鑰屼簡瑙h繃feign鐨勫悓瀛﹁繖閲屽氨鍙互鎷垮畠鍜宒ubbo瀵规瘮锛屽湪涓婇潰鐨勫浘涓紝feign灏辨槸鍦ㄥ井鏈嶅姟鏋舵瀯鎵挎媴rpc妗嗘灦锛岃�宒ubbo灏卞湪鍦ㄤ笂闈㈢殑SOA锛堬紙Service-Oriented
+Architecture锛岄潰鍚戞湇鍔$殑鏋舵瀯锛夋槸涓�涓粍浠舵ā鍨嬶紝瀹冨皢搴旂敤绋嬪簭鐨勪笉鍚屽姛鑳藉崟鍏冿紙绉颁负鏈嶅姟锛夎繘琛屾媶鍒嗭紝骞堕�氳繃杩欎簺鏈嶅姟涔嬮棿瀹氫箟鑹ソ鐨勬帴鍙e拰濂戠害鑱旂郴璧锋潵銆傦級鏋舵瀯涓壙鎷卹pc妗嗘灦鐨勮鑹层��
+
+SOA鏋舵瀯锛屽氨鍍忔槸澶ч儴闂ㄥ埗锛屼竴涓儴闂ㄧ鐨勪簨鍎挎瘮杈冨锛屽嚑涓浉鍏崇殑宸ヤ綔涓�鍧楀効骞诧紝杩欐牱澶у鍗忎綔璧锋潵鏂逛究锛屼絾鏄儴闂ㄥ拰閮ㄩ棬涔嬮棿杩樻槸寰椾簰鐩搁厤鍚堬紝鏈夋椂鍊欐矡閫氬浜嗗氨澶嶆潅浜嗐�傝�屼笖锛岃繖绉嶆ā寮忎笅锛屽ぇ瀹剁敤鐨勫伐鍏峰拰娴佺▼灏介噺缁熶竴锛屼负浜嗗ソ閰嶅悎銆�
+寰湇鍔℃灦鏋勫憿锛屽氨鍍忔槸灏忓洟闃熷埗锛屾瘡涓皬鍥㈤槦灏变笓鏀讳竴浠朵簨锛岀壒鍒笓娉紝鑷繁绠¤嚜宸遍偅涓�鍧楋紝鍑轰簡闂涔熶笉瀹规槗褰卞搷鍒汉銆傝繖绉嶆ā寮忕伒娲诲浜嗭紝姣忎釜灏忓洟闃熻繕鑳芥牴鎹嚜宸辩殑鍠滃ソ閫夋渶濂界殑宸ュ叿骞叉椿锛屾洿鏂版崲浠e揩銆備笉杩囷紝杩欎箞澶氬皬鍥㈤槦锛屾�庝箞璁╁畠浠珮鏁堝悎浣滐紝涔熷緱濂藉ソ璁捐涓�濂楄鍒欍��
+
+## DUBBO
+
+璇翠簡杩欎箞澶氾紝鍏跺疄dubbo鐨勭簿楂撳氨鏄�**鎶婅嚜宸辩殑api鏆撮湶鍑哄幓缁欏ぇ瀹讹紝鍏蜂綋鐨勫疄鐜扮户鎵胯嚜宸辩殑api鍘诲啓瀹炵幇鏂规硶銆�**
+
+浣嗘槸feign灏卞彲浠ュ畬鍏ㄨ劚绂籥pi鎻愪緵锛屽彲浠ユ彁渚涗竴涓猺estful鐨刪ttp鎺ュ彛锛岀劧鍚庡叾浠栨湇鍔″彲浠ョ洿鎺ラ�氳繃feign杩涜璋冪敤锛岃繖涔熷鑷翠簡feign鐨勮�﹀悎搴︽洿浣庯紝浣嗘槸feign鍦ㄥ疄闄呭紑鍙戣繃绋嬩腑涔熷彲浠ユā浠縟ubbo鏆撮湶api鐨勬柟寮忚繘琛屾灦鏋勭殑鎼缓銆�
+
+涔嬪墠鎴戜滑蹇�熸紨绀轰竴涓嬩簡dubbo锛孾姣忓ぉ涓�涓柊鐭ヨ瘑涔� SpringBoot+Dubbo 鐨勫揩閫熷叆闂╙(https://blog.csdn.net/csdnerM/article/details/125410232)
+瑕佷娇鐢╠ubbo棣栧厛瑕佹惌寤轰竴涓敞鍐屼腑蹇冿紝娉ㄥ唽涓績鐨勭洰鐨勫氨鏄负浜嗚鍏朵粬鐨勬湇鍔¤皟鐢╠ubbo鏈嶅姟锛屽湪dubbo瀹樻柟锛屾帹鑽愪娇鐢╖ookeeper浣滀负娉ㄥ唽涓績銆�
+
+[鍏徃灞呯劧杩樺湪鐢▃ookeeper锛屽悡寰楁垜椹笂瀛︿範浜嗙浉鍏冲懡浠わ紒](https://juejin.cn/post/7376930488738938920)
+
+[Linux瀹夎Zookeeper锛堝浘鏂囪В璇磋缁嗙増锛塢(https://masiyi.blog.csdn.net/article/details/121848173)
 
 
 
+> ![鍦ㄨ繖閲屾彃鍏ュ浘鐗囨弿杩癩(img/a39c0b1e57d24af9aa49d129a81cbe69.jpeg#pic_center)
+
+
+
+
+
+铏界劧涔嬪墠涔熷啓杩囦竴绡嘾ubbo鐨勫揩閫熷叆闂紝浣嗘槸鍐欑殑绠�鍗曪紝鏃堕殧涓ゅ勾锛岃繖娆′粙缁嶄竴浜汥ubbo鐨勯珮绾х壒鎬с��
+
+## 妗嗘灦
+
+鎴戜滑鍏堜粠妗嗘灦鐨勬惌寤鸿璧�
+
+![image-20240615204929083](img/a0907aaaaa99e487ec892bab78e1efeb.png)
+
+杩欐鎴戜滑涓�鍏卞缓浜嗗洓涓崟鐙殑妯″潡锛屼粬浠病鏈夊叡鍚岀殑鐖舵ā鍧楋紝浣嗘槸浠栦滑涔嬮棿鏈変緷璧栧叧绯伙紝浠栦滑涔嬮棿鐨勫叧绯绘槸杩欐牱鐨勶細
+
+![image-20240615210608867](img/3f2a3f339c9e70dc7655883a6eff85cb.png)
+
+鍦╯ervice妯″潡涓紩鍏ヤ簡Dubbo鐨刯ar鍖咃紝杩欐牱锛屼竴濂楁暣浣撶殑dubbo妯″潡妗嗘灦灏卞嚭鏉ヤ簡
+
+```
+      <dependency>
+            <groupId>com.alibaba.boot</groupId>
+            <artifactId>dubbo-spring-boot-starter</artifactId>
+            <version>0.2.0</version>
+        </dependency>
+```
+
+浠栦滑鐨勪綔鐢ㄥ垎鍒槸锛�
+
+api妯″潡鎻愪緵鏈�鍩虹鐨勫疄浣撶被锛屾灇涓剧被绛夛紝鏈�閲嶈鏄渶瑕佹毚闇插嚭鍘荤殑鎶借薄鎺ュ彛銆�
+
+service鍐欏叿浣撶殑鎺ュ彛鐨勫疄鐜扮被锛屾彁渚涘叿浣撶殑瀹炵幇绫汇��
+
+rpc-server閲岄潰鏄竴涓惎鍔ㄧ被锛屽洜涓轰緷璧杝ervice妯″潡锛屽彲浠ョ悊瑙d负鐢熶骇鎻愪緵鑰呫��
+
+web-server鍒欐槸涓昏鎻愪緵http鎺ュ彛缁欑涓夋柟锛屽鍓嶇璋冪敤锛屼篃鍙互寮曞叆鍏朵粬椤圭洰鐨刟pi妯″潡锛屼箣鍚庡彧瑕佹湁鐢熶骇鑰呮敞鍏ュ埌娉ㄥ唽涓績灏卞彲浠ユ彁渚涙湇鍔′簡锛岀洿鎺ヨ皟鐢╝pi閲岄潰鐨勬娊璞℃帴鍙f柟娉曘��
+
+璇磋繖涔堝锛屾垜浠潵鐪嬮噷闈㈢殑鍏蜂綋瀹炵幇浠g爜锛岀敱浜庣瘒骞呴棶棰橈紝璇风Щ鑷充唬鐮佷粨搴撴煡鐪嬩唬鐮侊細
+
+[https://gitee.com/wangfugui-ma/springboot-dubbo/tree/dubbo/](https://gitee.com/wangfugui-ma/springboot-dubbo/tree/dubbo/)
+
+閭d箞锛宒ubbo鏄渶瑕佹惌閰峼ookeeper鍘讳娇鐢紝鐢变簬涓婁竴绡囨枃绔犲凡缁忚杩囦簡锛岃繖閲屽氨涓嶅啀璧樿堪銆傛垜浠�庝箞鍘讳娇鐢╠ubbo鐨勪竴浜涢珮绾х壒鎬у憿
+
+## 楂樼骇鐗规��
+
+### 搴忓垪鍖�
+
+鐢变簬鎴戜滑鐨勫疄浣撶被鏄啓鍦╝pi閲岄潰鐨勶紝鑰宎pi鍙堟槸渚涘悇涓」鐩幓寮曠敤鐨勶紝鎵�浠ュ鏋滄垜浠鍦ㄥ叾浠栫殑椤圭洰涓幏鍙栬繖涓被锛屼緥濡傚湪杩欎釜椤圭洰涓殑queryUser鏂规硶涓��
+
+```java
+package com.zy.controller;
+
+
+import com.alibaba.dubbo.config.annotation.Reference;
+import com.zy.entity.User;
+import com.zy.service.UserService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class UserController {
+
+    @Reference//杩滅▼娉ㄥ叆
+    private UserService userService;
+
+
+    @GetMapping("/user")
+    public String user() {
+        User user = userService.queryUser();
+        return user.toString();
+    }
+}
+
+```
+
+鎴戜滑鐨刄ser瀵硅薄蹇呴』瀹炵幇Serializable鎺ュ彛锛屼緥濡傝繖鏍�
+
+```java
+package com.zy.entity;
+
+import java.io.Serializable;
+
+public class User implements Serializable {
+    private String name;
+    private Integer age;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+    public void setAge(Integer age) {
+        this.age = age;
+    }
+
+    @Override
+    public String toString() {
+        return "User{" +
+                "name='" + name + '\'' +
+                ", age=" + age +
+                '}';
+    }
+}
+
+```
+
+### 瓒呮椂
+
+#### 鐢熶骇鑰呰秴鏃�
+
+濡傛灉鎴戜滑鐨勭敓浜ц�呴渶瑕佽缃竴涓秴鏃舵椂闂达紝鎴戜滑鍙互鍦ㄦ彁渚涙柟鐨凷ervice娉ㄨВ涓姞鍏imeout灞炴�э紝灏卞儚杩欐牱锛�
+
+```java
+package com.zy.support;
+
+import com.alibaba.dubbo.config.annotation.Service;
+import com.zy.entity.User;
+import com.zy.service.UserService;
+import org.springframework.stereotype.Component;
+
+
+@Service(timeout = 3000)
+@Component
+public class UserServiceSupport implements UserService {
+
+    /**
+     * 鏌ヨuser
+     */
+    @Override
+    public User queryUser() {
+        try {
+            Thread.sleep(5000);
+        } catch (InterruptedException e) {
+            throw new RuntimeException(e);
+        }
+        User user = new User();
+        user.setAge(18);
+        user.setName("鐜嬪瘜璐�");
+        return user;
+    }
+}
+
+```
+
+杩欐牱褰撴垜浠殑controller鎺ュ彛璋冪敤瓒呰繃3绉掔殑鏃跺�欏氨浼氭姤閿欙細
+
+```
+com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout. start time: 2024-06-15 21:24:14.504, end time: 2024-06-15 21:24:17.511, client elapsed: 1 ms, server elapsed: 3006 ms, timeout: 3000 ms, request: Request [id=2, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=queryUser, parameterTypes=[], arguments=[], attachments={path=com.zy.service.UserService, interface=com.zy.service.UserService, version=0.0.0, timeout=3000}]], channel: /10.8.0.136:8061 -> /10.8.0.136:20885
+```
+
+杩欐牱鎴戜滑灏变粠鐢熶骇鏂瑰姞鍏ヤ簡瓒呮椂鎺у埗
+
+#### 娑堣垂鑰呰秴鏃�
+
+鍏跺疄鎴戜滑涔熷彲浠ヤ粠娑堣垂鑰呰繖杈规帶鍒惰秴鏃舵椂闂达紝灏卞儚杩欐牱锛�
+
+```
+package com.zy.controller;
+
+
+import com.alibaba.dubbo.config.annotation.Reference;
+import com.zy.entity.User;
+import com.zy.service.UserService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class UserController {
+
+    @Reference(timeout = 1000)//杩滅▼娉ㄥ叆
+    private UserService userService;
+
+
+    @GetMapping("/user")
+    public String user() {
+        User user = userService.queryUser();
+        return user.toString();
+    }
+}
+
+```
+
+鍦≧eference娉ㄨВ涓姞鍏imeout灞炴�т篃鏄彲浠ヨ揪鍒颁竴鏍风殑鏁堟灉锛�
+
+```
+com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout. start time: 2024-06-15 21:25:25.398, end time: 2024-06-15 21:25:26.399, client elapsed: 0 ms, server elapsed: 1001 ms, timeout: 1000 ms, request: Request [id=2, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=queryUser, parameterTypes=[], arguments=[], attachments={path=com.zy.service.UserService, interface=com.zy.service.UserService, version=0.0.0, timeout=1000}]], channel: /10.8.0.136:8570 -> /10.8.0.136:20885
+```
+
+### @Autowired
+
+闄や簡浣跨敤@Reference娉ㄨВ娉ㄥ叆dubbo鏈嶅姟澶栵紝杩樺彲浠ヤ娇鐢ˊAutowired鍘绘敞鍏ubbo鏈嶅姟
+
+![image-20240625163448223](img/1d70a633d9eb9f22e02faaa4283216b4.png)
+
+### 閰嶇疆鏂囦欢
+
+```
+dubbo.application.name=web-server
+dubbo.registry.address=zookeeper://127.0.0.1:2181
+```
+
+鍦ㄩ厤缃枃浠朵腑鍐欎笂鏈�鍩虹鐨勪袱涓厤缃紝dubbo.registry.address鍙互涓嶅甫zookeeper鍓嶇紑锛屼絾鏄鍔犱釜閰嶇疆key
+
+```
+# 濡傛灉涓嶅姞杩欎釜锛屽氨闇�瑕佸湪address閲岄潰鍔爖ookeeper://
+dubbo.registry.protocol=zookeeper
+```
+
+娉ㄦ剰杩欎釜閰嶇疆锛�
+
+```
+dubbo.protocol.port=20885
+```
+
+dubbo榛樿鐢�20880绔彛锛屽鏋滀綘闇�瑕佸湪涓�涓湇鍔″櫒涓婇潰鍚姩澶氫釜dubbo鏈嶅姟锛岄偅灏变笉鑳借浠栦滑鐨勭鍙e啿绐�
+
+```
+dubbo.registry.password=zk_password
+dubbo.registry.username=zk_user
+```
+
+濡傛灉浣犵殑鑺傜偣鏈塧cl鏉冮檺锛屽垯鍙兘闇�瑕佸姞涓婅繖涓や釜閰嶇疆锛屾浛鎹alue
+
+濡傛灉浣犺繕涓嶇煡閬揳cl鏉冮檺鏄粈涔堬紝鎺ㄨ崘浣犵湅涓�涓嬭繖绡囨枃绔�
+
+[鍏徃灞呯劧杩樺湪鐢▃ookeeper锛屽悡寰楁垜椹笂瀛︿範浜嗙浉鍏冲懡浠わ紒](https://juejin.cn/post/7376930488738938920)
+
+### @EnableDubbo
+
+璁板緱鍦ㄥ惎鍔ㄧ被寮�鍚繖涓敞瑙o紝鍚﹀垯涓嶈兘浣跨敤dubbo鐨勭浉鍏虫湇鍔★紝浣犳噦鐨勩�傘�傘�傘��
+
+> ![鍦ㄨ繖閲屾彃鍏ュ浘鐗囨弿杩癩(img/31dc8042deb97d9fdd67c146bd3fac11.png)
+
diff --git a/api/pom.xml b/api/pom.xml
new file mode 100644
index 0000000..eebfcd9
--- /dev/null
+++ b/api/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.zy</groupId>
+    <artifactId>api</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+</project>
\ No newline at end of file
diff --git a/api/src/main/java/com/zy/entity/User.java b/api/src/main/java/com/zy/entity/User.java
new file mode 100644
index 0000000..28b81a0
--- /dev/null
+++ b/api/src/main/java/com/zy/entity/User.java
@@ -0,0 +1,32 @@
+package com.zy.entity;
+
+import java.io.Serializable;
+
+public class User implements Serializable {
+    private String name;
+    private Integer age;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+    public void setAge(Integer age) {
+        this.age = age;
+    }
+
+    @Override
+    public String toString() {
+        return "User{" +
+                "name='" + name + '\'' +
+                ", age=" + age +
+                '}';
+    }
+}
diff --git a/api/src/main/java/com/zy/service/UserService.java b/api/src/main/java/com/zy/service/UserService.java
new file mode 100644
index 0000000..1bccfc8
--- /dev/null
+++ b/api/src/main/java/com/zy/service/UserService.java
@@ -0,0 +1,12 @@
+package com.zy.service;
+
+import com.zy.entity.User;
+
+//todo 杩欓噷鍐欎竴涓嚜瀹氫箟娉ㄨВ锛屼箣鍚庨�氳繃鑷畾涔夋敞瑙f潵鑾峰彇璇ユ帴鍙e拰瀹炵幇绫诲皢鍏舵敞鍐屽埌娉ㄥ唽涓績
+public interface UserService {
+
+    /**
+     * 鏌ヨuser
+     */
+    public User queryUser();
+}
diff --git a/rpc-server/pom.xml b/rpc-server/pom.xml
new file mode 100644
index 0000000..7931cf0
--- /dev/null
+++ b/rpc-server/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.5.3</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+
+
+    <groupId>com.zy</groupId>
+    <artifactId>rpc-server</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+
+        <dependency>
+            <groupId>com.zy</groupId>
+            <artifactId>service</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/rpc-server/src/main/java/com/zy/SpringBootRpcServerApplication.java b/rpc-server/src/main/java/com/zy/SpringBootRpcServerApplication.java
new file mode 100644
index 0000000..454d10d
--- /dev/null
+++ b/rpc-server/src/main/java/com/zy/SpringBootRpcServerApplication.java
@@ -0,0 +1,17 @@
+package com.zy;
+
+import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+
+@SpringBootApplication
+@EnableDubbo
+public class SpringBootRpcServerApplication {
+
+
+    public static void main(String[] args) {
+        SpringApplication.run(SpringBootRpcServerApplication.class, args);
+    }
+}
+
diff --git a/rpc-server/src/main/resources/application.properties b/rpc-server/src/main/resources/application.properties
new file mode 100644
index 0000000..34c3e6c
--- /dev/null
+++ b/rpc-server/src/main/resources/application.properties
@@ -0,0 +1,14 @@
+# ????
+spring.application.name=rpc-server
+server.port=8082
+dubbo.application.name=rpc-server
+dubbo.registry.address=zookeeper://127.0.0.1:2181
+#dubbo.registry.protocol=zookeeper
+#dubbo.registry.password=dreamtech
+#dubbo.registry.username=zk_user
+dubbo.protocol.name=dubbo
+dubbo.protocol.port=20880
+dubbo.monitor.protocol=registry
+
+
+
diff --git a/rpc-server/target/classes/application.properties b/rpc-server/target/classes/application.properties
new file mode 100644
index 0000000..fe44e2c
--- /dev/null
+++ b/rpc-server/target/classes/application.properties
@@ -0,0 +1,18 @@
+# ????
+spring.application.name=rpc-server
+
+server.port=8082
+
+dubbo.application.name=rpc-server
+dubbo.registry.address=zookeeper://127.0.0.1:2181
+#dubbo.registry.protocol=zookeeper
+#dubbo.registry.password=dreamtech
+#dubbo.registry.username=zk_user
+
+dubbo.protocol.name=dubbo
+dubbo.protocol.port=20880
+
+dubbo.monitor.protocol=registry
+
+
+
diff --git a/service/pom.xml b/service/pom.xml
new file mode 100644
index 0000000..a2c3ba0
--- /dev/null
+++ b/service/pom.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.zy</groupId>
+    <artifactId>service</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <dubbo.version>2.7.8</dubbo.version>
+        <curator.version>4.2.0</curator.version>
+        <curator-recipes.version>2.8.0</curator-recipes.version>
+        <zookeeper.version>3.6.3</zookeeper.version>
+    </properties>
+
+
+    <dependencies>
+        <!-- Dubbo Spring Boot Starter -->
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-spring-boot-starter</artifactId>
+            <version>2.7.8</version>
+        </dependency>
+
+
+        <!-- Dubbo Spring Boot Starter -->
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-spring-boot-starter</artifactId>
+            <version>${dubbo.version}</version>
+
+        </dependency>
+
+        <!-- zookeeper娉ㄥ唽涓績 闇�瑕佸鍏ookeeper渚濊禆  -->
+        <dependency>
+            <groupId>org.apache.zookeeper</groupId>
+            <artifactId>zookeeper</artifactId>
+            <version>${zookeeper.version}</version>
+            <!-- 鎻愮ず涓巣ookeeper涓殑slf4j-log4j12-1.7.29.jar 鍖呭啿绐�-->
+            <!--鎺掗櫎杩欎釜slf4j-log4j12-->
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>log4j</groupId>
+                    <artifactId>log4j</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!-- Zookeeper 瀹㈡埛绔� -->
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-framework</artifactId>
+            <version>${curator.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-recipes</artifactId>
+            <version>${curator-recipes.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.zy</groupId>
+            <artifactId>api</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file
diff --git a/service/src/main/java/com/zy/support/UserServiceSupport.java b/service/src/main/java/com/zy/support/UserServiceSupport.java
new file mode 100644
index 0000000..cff6b50
--- /dev/null
+++ b/service/src/main/java/com/zy/support/UserServiceSupport.java
@@ -0,0 +1,26 @@
+package com.zy.support;
+
+import com.zy.entity.User;
+import com.zy.service.UserService;
+import org.apache.dubbo.config.annotation.DubboService;
+
+
+@DubboService // 璇ユ敞瑙g敤浜庡皢褰撳墠绫诲璞″瓨鍏pring瀹瑰櫒涓�,鏃㈠彲浠ユ湰椤圭洰鏈嶅姟浣跨敤锛岀埗鎺ュ彛娉ㄨВ鑳藉姏涔熷彲浠ユ彁渚涚粰鍏朵粬椤圭洰浣跨敤
+public class UserServiceSupport implements UserService {
+
+    /**
+     * 鏌ヨuser
+     */
+    @Override
+    public User queryUser() {
+//        try {
+//            Thread.sleep(5000);
+//        } catch (InterruptedException e) {
+//            throw new RuntimeException(e);
+//        }
+        User user = new User();
+        user.setAge(18);
+        user.setName("寮犱笁");
+        return user;
+    }
+}
diff --git a/web-server/pom.xml b/web-server/pom.xml
new file mode 100644
index 0000000..28ee17b
--- /dev/null
+++ b/web-server/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.5.3</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+
+
+    <groupId>com.zy</groupId>
+    <artifactId>web-server</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+
+        <dependency>
+            <groupId>com.zy</groupId>
+            <artifactId>service</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/web-server/src/main/java/com/zy/SpringBootAplication.java b/web-server/src/main/java/com/zy/SpringBootAplication.java
new file mode 100644
index 0000000..8aef8f3
--- /dev/null
+++ b/web-server/src/main/java/com/zy/SpringBootAplication.java
@@ -0,0 +1,17 @@
+package com.zy;
+
+import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+
+@SpringBootApplication
+@EnableDubbo
+public class SpringBootAplication {
+
+
+    public static void main(String[] args) {
+        SpringApplication.run(SpringBootAplication.class, args);
+    }
+}
+
diff --git a/web-server/src/main/java/com/zy/controller/UserController.java b/web-server/src/main/java/com/zy/controller/UserController.java
new file mode 100644
index 0000000..7520664
--- /dev/null
+++ b/web-server/src/main/java/com/zy/controller/UserController.java
@@ -0,0 +1,22 @@
+package com.zy.controller;
+
+
+import com.zy.entity.User;
+import com.zy.service.UserService;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class UserController {
+
+    @DubboReference(timeout = 1000)//杩滅▼娉ㄥ叆
+    private UserService userService;
+
+
+    @GetMapping("/user")
+    public String user() {
+        User user = userService.queryUser();
+        return user.toString();
+    }
+}
diff --git a/web-server/src/main/resources/application.properties b/web-server/src/main/resources/application.properties
new file mode 100644
index 0000000..c700ece
--- /dev/null
+++ b/web-server/src/main/resources/application.properties
@@ -0,0 +1,12 @@
+# ????
+spring.application.name=web-server
+# ???? WEB ????
+server.port=8083
+dubbo.protocol.name=dubbo
+dubbo.application.name=web-server
+dubbo.registry.address=zookeeper://127.0.0.1:2181
+#dubbo.registry.password=dreamtech
+#dubbo.registry.username=zk_user
+dubbo.monitor.protocol=registry
+dubbo.protocol.port=20885
+
diff --git a/web-server/target/classes/application.properties b/web-server/target/classes/application.properties
new file mode 100644
index 0000000..bb6c1d1
--- /dev/null
+++ b/web-server/target/classes/application.properties
@@ -0,0 +1,14 @@
+# ????
+spring.application.name=web-server
+# ???? WEB ????
+server.port=8083
+
+dubbo.protocol.name=dubbo
+dubbo.application.name=web-server
+dubbo.registry.address=zookeeper://127.0.0.1:2181
+#dubbo.registry.password=dreamtech
+#dubbo.registry.username=zk_user
+dubbo.monitor.protocol=registry
+
+dubbo.protocol.port=20885
+

--
Gitblit v1.9.1