直接改造上一篇文章创建的工程
一直next就行
<dependency>
<groupId>com.why</groupId>
<artifactId>ch06-interface</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>4.1.0</version>
</dependency>
<?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服务提供者名称:保证唯一-->
<!--选择dubbo.apache.org的那个-->
<dubbo:application name="ch06-StudentService-provide"/>
<!--声明dubbo使用的协议和端口,dubbo官方推荐使用的协议为dubbo,端口号默认为20880-->
<dubbo:protocol name="dubbo" port="20880"/>
<!--指定注册中心的地址和端口号-->
<dubbo:registry address="zookeeper://localhost:2181"/>
<!--暴露服务(使用注册中心)-->
<!--这里就不需要使用registry属性-->
<dubbo:service interface="com.why.service.StudentService" ref="StudentService" />
<bean id="StudentService" class="com.why.service.Imp.StudentServiceImp"/>
</beans>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>4.1.0</version>
</dependency>
<?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服务提供者名称:保证唯一-->
<!--选择dubbo.apache.org的那个-->
<dubbo:application name="ch06-StudentService-consumer"/>
<!--指定注册中心-->
<dubbo:registry address="zookeeper://localhost:2181"/>
<!--引用远程服务接口-->
<!--这里也不需要registry属性了-->
<dubbo:reference id="userService" interface="com.why.service.StudentService" />
</beans>
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/m0_60117382/article/details/121296618
内容来源于网络,如有侵权,请联系作者删除!