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"/>

常用标签

原文地址:https://www.cnblogs.com/riches/p/11193499.html

时间: 2024-08-01 04:58:36

dubbo学习(二)配置dubbo XML方式配置的相关文章

跟着刚哥学习Spring框架--通过XML方式配置Bean(三)

Spring配置Bean有两种形式(XML和注解) 今天我们学习通过XML方式配置Bean 1. Bean的配置方式 通过全类名(反射)的方式   √ id:标识容器中的bean.id唯一. √ class:bean的全类名,通过反射的方式在IOC容器中创建Bean,所以要求Bean中必须有无参的构造器 2.依赖注入的方式 1)属性注入:通过setter方法注入Bean的属性值或依赖的对象 属性注入使用<Property>元素,使用name指定Bean的属性名称,使用value指定Bean的属

跟着刚哥学习Spring框架--通过注解方式配置Bean(四)

组件扫描:Spring能够从classpath下自动扫描,侦测和实例化具有特定注解的组件. 特定组件包括: 1.@Component:基本注解,识别一个受Spring管理的组件 2.@Respository:标识持久层组件 3.@Service:标识业务层组件 4.@Controller:标识表现层组件 Spring 有默认的命名策略: 使用非限定类名, 第一个字母小写. 也可以在注解中通过 value 属性值标识组件的名称 当在组件类上使用了特定的注解之后, 还需要在 Spring 的配置文件

Spring学习(五)bean装配详解之 【XML方式配置】

本文借鉴:Spring学习(特此感谢!) 一.配置Bean的方式及选择 配置方式 在 XML 文件中显式配置 在 Java 的接口和类中实现配置 隐式 Bean 的发现机制和自动装配原则 方式选择的原则 最优先:通过隐式 Bean 的发现机制和自动装配的原则. 基于约定优于配置的原则,这种方式应该是最优先的 好处:减少程序开发者的决定权,简单又不失灵活. 其次:Java 接口和类中配置实现配置 在没有办法使用自动装配原则的情况下应该优先考虑此类方法 好处:避免 XML 配置的泛滥,也更为容易.

SpringBoot填坑系列---XML方式配置数据库

本次只是简单的运用SpringBoot搭建框架,对其原理并不做深入的探究 1.POM文件 1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaL

dubbo系列二、dubbo+zookeeper+dubboadmin分布式服务框架搭建(windows平台)

一.zookeeper配置中心安装 1.下载安装包,zookeeper-3.4.6.tar.gz 2.解压安装包,修改配置文件 参考zookeeper-3.4.6/conf/zoo_sample.cfg文件,同步录下建立zoo.cfg,配置如下: # The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can tak

springboot-mybatis配置(xml)/springboot-jpa配置

#springboot-mybatis配置(xml) spring.datasource.url=jdbc:mysql://localhost:3306/test spring.datasource.username=root spring.datasource.password=123456 spring.datasource.driver-class-name=com.mysql.jdbc.Driver mybatis.mapper-locations=classpath*:mybatis/

Java 基于quartz实现定时 之二(XML方式配置)

<!-- 在spring核心配置文件中进行如下配置 --> <!-- Spring基于quartz定时任务 --> <bean id="triggerByBeanTwo" class="cn.zr.pringmvctest.trigger.TriggerByBeanTwo"></bean> <!-- jobDetail --> <bean id="triggerByBeanTwoJob&qu

dubbo学习 二 dubbo源码大致查阅

源码的解析在官网都已经写的非常详细,可以参考:http://dubbo.io/Developer+Guide-zh.htm 服务提供者暴露一个服务的详细过程 首先ServiceConfig类拿到对外提供服务的实际类ref(如:HelloWorldImpl),然后通过ProxyFactory类的getInvoker方法使用ref生成一个AbstractProxyInvoker实例,到这一步就完成具体服务到Invoker的转化.接下来就是Invoker转换到Exporter的过程. Dubbo处理服

在spring的配置中,基于注解方式是否比xml方式配置更好?——翻译

简短的回答就是“看情况了”.长篇大论来说(辩证的看待),每种方式都有利弊,通常来说,这取决于开发者选择最适合他们的策略.由于注解的定义方式,在其声明中提供了大量上下文,从而导致更短更简洁的配置.但是,XML的方式优势在于连接组件时解耦源代码或无需重新编译.一些开发人员更喜欢将配置连接靠近源头,而另一些则认为注释类不再是POJO,而且配置变得分散且难以控制. 不管是哪种方式,spring可以兼容两种风格并且混合使用都可以.值得提出的是,通过其JavaConfig选项,Spring允许以非侵入方式使