1. 项目 jar  -----提供接口

2. 项目 jar  -----接口实现   provider
启动zk

main方法启动 start applicationContext.xml

 

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://code.alibabatech.com/schema/dubbo
    http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

    <!-- 提供方应用信息,用于计算依赖关系 -->
    <dubbo:application name="test_provider" />

    <!-- 使用zookeeper注册中心暴露服务地址 -->
    <dubbo:registry address="zookeeper://localhost:2181" />
    <dubbo:monitor protocol="registry"/>  

    <!-- 用dubbo协议在20880端口暴露服务 -->
    <dubbo:protocol name="dubbo" port="20880" />



    <!-- 声明需要暴露的服务接口 -->
    <dubbo:service interface="com.beta_ai.med.service.TestService" ref="testService" />

    <!-- 具体的实现bean -->
    <bean />
</beans>

3. 项目 war
调用服务

<?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://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans  
       http://www.springframework.org/schema/beans/spring-beans.xsd  
       http://code.alibabatech.com/schema/dubbo  
       http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

    <!-- 提供方应用信息,用于计算依赖关系 -->
    <dubbo:application name="test_consumer" />

    <!-- 使用zookeeper注册中心暴露服务地址 -->
    <dubbo:registry address="zookeeper://localhost:2181" />
    <dubbo:monitor protocol="registry"/>  

    <!-- 声明需要暴露的服务接口 -->
    <dubbo:reference interface="com.beta_ai.med.service.TestService" />

</beans>

 

相关文章:

  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-05-25
  • 2022-01-19
  • 2021-08-06
  • 2021-08-19
猜你喜欢
  • 2021-11-28
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-06-17
相关资源
相似解决方案