Dubbo没有注册中心的时候开发步骤

服务提供者开发步骤:
1.定义服务接口(该接口需要单独打包,在服务方和消费者双方共享)
2.在服务提供方实现接口(对服务消费者隐藏)
3.用Spring配置声明暴露服务
(1.声明服务的名称 <dubbo:application name="">
2.暴露服务:<dubbo:service interface=“接口的权限定名称” ref=“实现该接口的beanid” protocol=“访问服务使用的协议” registry=“注册中心”>
3.服务具体实现)
4.加载Spring配置创建bean对象

服务消费者的开发步骤:
1.通过Spring配置引用远程服务
2.加载Spring配置,并调用远程服务:(也可以使用Ioc注入)

<dubbo:application name=“消费者名称”/>

<!-- 生命使用服务
	id : 对象的名称  这个对象是dubbo使用动态代理创建的服务者接口实现类的
	interface : 服务的接口 (面向接口编程)
	url : 访问服务的  地址信息 
	   -->
<dubbo:reference interface="接口"
	    		 id="weatherService" url="dubbo://localhost:20880(服务的访问地址)" registry="N/A" ></dubbo:reference>

<!-- 声明Service对象 -->
<bean id="invokeService" class="com.bjpowernode.service.InvokeService">
	<property name="wservice" ref="weatherService"></property>
</bean>

猜你喜欢

转载自blog.csdn.net/weixin_43170586/article/details/83244562