Posted 鍏ㄦ爤娴嬭瘯绗旇

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了相关的知识,希望对你有一定的参考价值。


鐐瑰嚮鈥?/span> 鍏ㄦ爤娴嬭瘯绗旇 鈥濓紝閫夋嫨鈥滄槦鏍囸煍濃€?/span>

Dubbo鏄竴娆鹃珮鎬ц兘銆佽交閲忕骇鐨勫紑婧怞ava RPC妗嗘灦銆?br>

寰堝鏈嬪弸鎯崇粌涔燿ubbo鎺ュ彛娴嬭瘯锛屼絾鏄嫤浜庢病鏈夋帴鍙h€屾斁寮冿紝涓嬮潰鎴戝氨甯﹀ぇ瀹跺紑鍙戜竴涓畝鍗曠殑dubbo鎺ュ彛銆?/p>


鎺ュ彛闇€姹?/strong>

瀹㈡埛绔緭鍏ncleyong锛堝綋鐒讹紝涔熷彲浠ヨ緭鍏ュ叾瀹冨瓧绗︿覆锛夛紝鏈嶅姟绔繑鍥瀐ello uncleyong


寮€鍙戠幆澧?/strong>

jdk + idea + maven + zookeeper

jdk瀹夎锛歨ttps://www.cnblogs.com/uncleyong/p/10732951.html

idea瀹夎锛歨ttps://www.cnblogs.com/uncleyong/p/10971923.html

maven瀹夎锛歨ttps://www.cnblogs.com/uncleyong/p/10743181.html

zookeeper瀹夎锛歨ttps://www.cnblogs.com/uncleyong/p/10737119.html


common寮€鍙?/strong>

idea涓垱寤烘ā鍧梔ubbo-common

瀛樻斁鍏叡鐨勫疄浣撶被銆佹帴鍙?/p>

package com.uncleyong.dubbotest.service;
public interface SayHelloToClient { public String sayHello(String name);}

鐒跺悗mvn install鎵撳寘锛屼緵provider鍙奵onsumer鍦╬om鏂囦欢涓紩鍖呫€€

鎯崇粌涔燿ubbo鎺ュ彛娴嬭瘯锛屼絾鏄病鎺ュ彛锛? class=


provider寮€鍙?/strong>

idea涓垱寤烘ā鍧梔ubbo_provider

鍒涘缓瀹炵幇绫?/p>

package com.uncleyong.dubbotest.service.impl;
import com.uncleyong.dubbotest.service.SayHelloToClient;

public class SayHelloToClientImpl implements SayHelloToClient {
public String sayHello(String name){ System.out.println("from client 锛? + name); return "hello, " + name; }}

閰嶇疆鏂囦欢锛宲rovider.xml

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://dubbo.apache.org/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
<dubbo:application name="dubbo-provider"/>
<!-- 浣跨敤zookeeper骞挎挱娉ㄥ唽涓績鏆撮湶鏈嶅姟鍦板潃 --> <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!-- 鐢╠ubbo鍗忚鍦?0880绔彛鏆撮湶鏈嶅姟 --> <dubbo:protocol name="dubbo" port="20888"/>
<!-- 澹版槑闇€瑕佹毚闇茬殑鏈嶅姟鎺ュ彛 --> <dubbo:service interface="com.uncleyong.dubbotest.service.SayHelloToClient" ref="sayhellotoclient"/>

<!-- 鍜屾湰鍦癰ean涓€鏍峰疄鐜版湇鍔?--> <bean id="sayhellotoclient" class="com.uncleyong.dubbotest.service.impl.SayHelloToClientImpl"/>
</beans>

鍒涘缓涓昏繍琛屾枃浠讹紝ProviderMain

package com.uncleyong.dubbotest.main;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ProviderMain { public static void main(String[] args) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] {"provider.xml"}); context.start(); System.out.println("娉ㄥ唽鎴愬姛锛屽鎯抽€€鍑猴紝鎸変换鎰忛敭閫€鍑?); System.in.read(); // 鎸変换鎰忛敭閫€鍑?/span> }}


consumer寮€鍙?/strong>

idea涓垱寤烘ā鍧梔ubbo_consumer

涓昏繍琛屾枃浠?/p>

package com.uncleyong.dubbotest.main;
import com.uncleyong.dubbotest.service.SayHelloToClient;import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.Scanner;

public class ConsumerMain { public static void main(String[] args) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] {"consumer.xml"}); context.start(); // 鑾峰彇杩滅▼鏈嶅姟浠g悊 SayHelloToClient say = (SayHelloToClient) context.getBean("sayhellotoclient"); // 鎵ц杩滅▼鏂规硶 String res = say.sayHello("UncleYong"); // 鏄剧ず璋冪敤缁撴灉 System.out.println(res); new Scanner(System.in).next(); }}

閰嶇疆鏂囦欢锛宑onsumer.xml

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://dubbo.apache.org/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">

<dubbo:application name="dubbo-consumer"/>
<!-- 浣跨敤zookeeper骞挎挱娉ㄥ唽涓績鏆撮湶鍙戠幇鏈嶅姟鍦板潃 --> <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!-- 鐢熸垚杩滅▼鏈嶅姟浠g悊锛屽彲浠ュ拰鏈湴bean涓€鏍蜂娇鐢╠emoService --> <dubbo:reference id="sayhellotoclient" interface="com.uncleyong.dubbotest.service.SayHelloToClient"/>
</beans>


杩愯缁撴灉

鍏堝惎鍔▃ookeeper锛岃繘鍏ookeeper鐨刡in鐩綍锛岀偣鍑汇€恴kServer.cmd銆?/p>

鎯崇粌涔燿ubbo鎺ュ彛娴嬭瘯锛屼絾鏄病鎺ュ彛锛? class=

鍚姩provider

鎯崇粌涔燿ubbo鎺ュ彛娴嬭瘯锛屼絾鏄病鎺ュ彛锛? class=

鏈嶅姟娉ㄥ唽鎴愬姛

鎯崇粌涔燿ubbo鎺ュ彛娴嬭瘯锛屼絾鏄病鎺ュ彛锛? class=

鎯崇粌涔燿ubbo鎺ュ彛娴嬭瘯锛屼絾鏄病鎺ュ彛锛? class=

鍚姩consumer锛屽彲浠ョ湅鍒拌緭鍑轰簡缁撴灉

鎯崇粌涔燿ubbo鎺ュ彛娴嬭瘯锛屼絾鏄病鎺ュ彛锛? class=

鎯崇粌涔燿ubbo鎺ュ彛娴嬭瘯锛屼絾鏄病鎺ュ彛锛? class=

鍦╬rovider绔紝涔熷彲浠ョ湅鍒板鎴风鍙戣繃鏉ョ殑娑堟伅

鎯崇粌涔燿ubbo鎺ュ彛娴嬭瘯锛屼絾鏄病鎺ュ彛锛? class= 

鑷虫锛屽紑鍙戝畬鎴愶紝涓嬩竴绡囷紝鍒嗕韩鐢╦meter娴嬭瘯dubbo鎺ュ彛銆?/p>

 

鎶涚爾寮曠帀锛屾杩庝氦娴侊紱

澹版槑锛氬皝闈㈠浘鐗囨潵婧愪簬缃戠粶锛屽鏈変镜鏉冿紝璇疯仈绯诲垹闄ゃ€?/span>


END


鎯崇粌涔燿ubbo鎺ュ彛娴嬭瘯锛屼絾鏄病鎺ュ彛锛? class=


鏄熸爣|鍦ㄧ湅|鐣欒█|杞彂鍒嗕韩锛岄搧绮?/strong>


闀挎寜浜岀淮鐮佸叧娉紝绗竴鏃堕棿鑾峰彇骞茶揣

鎯崇粌涔燿ubbo鎺ュ彛娴嬭瘯锛屼絾鏄病鎺ュ彛锛?></strong></span> 
     </section> 
     <section class=



鎬ц兘娴嬭瘯浜ゆ祦缇?/strong>



鐐瑰嚮銆?/span>闃呰鍘熸枃銆?/span>

以上是关于的主要内容,如果未能解决你的问题,请参考以下文章

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数

VSCode自定义代码片段8——声明函数