dubbo学习(二)配置dubbo XML方式配置

provider(生产者)

复制代码
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
       xmlns="http://www.springframework.org/schema/beans"
       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="demo-provider"/>
    <!--配置注册中心-->
    <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
    <!--配置服务协议-->
    <dubbo:protocol name="dubbo" port="20890"/>
    <!--配置服务暴露-->
    <bean id="demoService" class="org.apache.dubbo.samples.basic.impl.DemoServiceImpl"/>
    <dubbo:service interface="org.apache.dubbo.samples.basic.api.DemoService" ref="demoService"/>
</beans>
复制代码

consumer(消费者)

复制代码
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
       xmlns="http://www.springframework.org/schema/beans"
       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="demo-consumer"/>
    <!--配置注册中心-->
    <dubbo:registry group="aaa" address="zookeeper://127.0.0.1:2181"/>
    <!--配置代理-->
    <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.samples.basic.api.DemoService"/>
</beans>
复制代码

monitor(监视器)

<!--配置监控器:通过注册中心获取monitor地址后建立链接-->
<dubbo:monitor protocal="registry"/>
<!--配置监控器:绕过注册中心,直连monitor-->
<dubbo:monitor address="dubbo://127.0.0.1:7070/xxxMonitorService"/>

常用标签

posted @   有梦想的肥宅  阅读(7866)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示