DBUUO相关配置代码介绍
2017-07-09 11:53
288 查看
相关代码介绍---生产者
zookeeper使用需要有消费者和生产者,生产者提供制定的接口内容后,消费者才可以使用;<?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管理页面比较清晰是哪个应用暴露出来的 --> <dubbo:application name="dubbo_provider"></dubbo:application> <!-- 使用zookeeper注册中心暴露服务地址 --> <dubbo:registry address="zookeeper://127.0.0.1:2181" check="false" subscribe="false" register=""></dubbo:registry> <!-- 要暴露的服务接口 --> <dubbo:service interface="com.zooker.RegistryService" ref="testRegistryService" /> </beans>
dubbo:registry address="zookeeper://127.0.0.1:2181"表示注册地址;zookeeper在项目启动的时候,将会对连接该地址;
dubbo:service表示注册的接口内容;其中
ref="testRegistryService"是需要在spring配置文件配置的,依获取对象;
<bean id="testRegistryService" class="com.zooker.impl.RegistryServiceImpl"></bean>spring中注入的内容 ;该对象对了的class是个实体类
消费者
做为消费者,需要知道从何处获取到zookeeper提供的接口;其次,将这些接口引入到自身的服务器中;<?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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schem 4000 a/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd" default-lazy-init="false" > <dubbo:application name="dubbo_consumer"></dubbo:application> <!-- 使用zookeeper注册中心暴露服务地址 --> <dubbo:registry address="zookeeper://127.0.0.1:2181" check="false"></dubbo:registry> <!-- 要引用的服务 --> <dubbo:reference interface="com.zooker.RegistryService" id="registryService"></dubbo:reference> </beans>
dubbo:registry address="zookeeper://127.0.0.1:2181"表示生产者获取接口的地址;
dubbo:reference interface="com.zooker.RegistryService" id="registryService"从zookeeper中获取的接口对象;
@Autowired RegistryService registryService;
在java中只需要将在配置在xml文件中的id对象;即
id="registryService"添加到对象当中即可
zookeeper 会自动的帮助你找的应该实例化的对象;
相关代码介绍---生产者
zookeeper使用需要有消费者和生产者,生产者提供制定的接口内容后,消费者才可以使用;<?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管理页面比较清晰是哪个应用暴露出来的 --> <dubbo:application name="dubbo_provider"></dubbo:application> <!-- 使用zookeeper注册中心暴露服务地址 --> <dubbo:registry address="zookeeper://127.0.0.1:2181" check="false" subscribe="false" register=""></dubbo:registry> <!-- 要暴露的服务接口 --> <dubbo:service interface="com.zooker.RegistryService" ref="testRegistryService" /> </beans>
dubbo:registry address="zookeeper://127.0.0.1:2181"表示注册地址;zookeeper在项目启动的时候,将会对连接该地址;
dubbo:service表示注册的接口内容;其中
ref="testRegistryService"是需要在spring配置文件配置的,依获取对象;
<bean id="testRegistryService" class="com.zooker.impl.RegistryServiceImpl"></bean>spring中注入的内容 ;该对象对了的class是个实体类
消费者
做为消费者,需要知道从何处获取到zookeeper提供的接口;其次,将这些接口引入到自身的服务器中;<?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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd" default-lazy-init="false" > <dubbo:application name="dubbo_consumer"></dubbo:application> <!-- 使用zookeeper注册中心暴露服务地址 --> <dubbo:registry address="zookeeper://127.0.0.1:2181" check="false"></dubbo:registry> <!-- 要引用的服务 --> <dubbo:reference interface="com.zooker.RegistryService" id="registryService"></dubbo:reference> </beans>
dubbo:registry address="zookeeper://127.0.0.1:2181"表示生产者获取接口的地址;
dubbo:reference interface="com.zooker.RegistryService" id="registryService"从zookeeper中获取的接口对象;
@Autowired RegistryService registryService;
在java中只需要将在配置在xml文件中的id对象;即
id="registryService"添加到对象当中即可
zookeeper 会自动的帮助你找的应该实例化的对象;
相关文章推荐
- 本文给出了一种方便实用的解决大文件的读取、存储等处理的方法,并结合相关程序代码对具体的实现过程进行了介绍
- 简单介绍一下linux下的ftp服务及相关配置
- 使用Capistrano向EC2部署Django代码--关于SSH相关的配置
- iOS高德地图的相关配置和简单演示代码
- mysql安装图解(详细步骤),配置,相关图形工具介绍及使用,中文支持
- Python代码中os.path常见属性的相关介绍 from 路人甲
- StyleCop(C#代码规范分析工具)---1.介绍,下载及配置
- session有效期配置 相关介绍(下)
- 关于apache服务的相关配置介绍
- 简单介绍一下linux下的ftp服务及相关配置
- Linux系统管理.Raid的配置文件说明及相关命令介绍
- Squid代理服务器(缓存代理)介绍及相关配置
- SSH SecureCRT介绍以及相关使用配置
- 根文件系统中相关配置文件的介绍
- UNIX GUN VIM 相关配置文件介绍
- Nginx+PHP配置相关进程的简要介绍
- 网络相关配置文件介绍
- vim代码智能提示功能及相关配置