标签:reference 启动 java color 用户名 img admin swagger odi
参考资料:https://segmentfault.com/a/1190000009568509
https://segmentfault.com/a/1190000004654903
0. 环境
Java: jdk1.8.0_144
OS: Windows 10(宿主机192.168.1.105)/Ubuntu 15.10(虚拟机192.168.1.21)
Tomcat: apache-tomcat-7.0.68
1. 下载zookeeper部署到虚拟机
2. 下载dubbo源码后打包dubbo-admin并部署到虚拟机
3. 创建项目并完成配置
<?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="dubbo-demo-provider" /> <!-- zookeeper注册中心 --> <dubbo:registry address="zookeeper://192.168.1.21:2181" /> <dubbo:protocol name="dubbo" port="20880" /> <!-- 和本地bean一样实现服务 --> <bean id="demoService1" class="org.lxp.dubbo.service.DemoServiceImpl" /> <bean id="demoService2" class="org.lxp.dubbo.service.DemoServiceImpl2" /> <!-- 向注册中心注册暴漏服务地址,注册服务 --> <dubbo:service interface="org.lxp.dubbo.service.DemoService" ref="demoService1" executes="10" version="1.0.1" /> <dubbo:service interface="org.lxp.dubbo.service.DemoService" ref="demoService2" executes="10" version="1.0.2" /> </beans>
<?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="dubbo-demo-consumer" /> <dubbo:registry address="zookeeper://192.168.1.21:2181" /> <!-- 向注册中心订阅服务 --> <dubbo:reference id="demoService1" interface="org.lxp.dubbo.service.DemoService" version="1.0.1" /> <dubbo:reference id="demoService2" interface="org.lxp.dubbo.service.DemoService" version="1.0.2" /> </beans>
4. 启动发布服务
5. 启动消费服务并测试
基于dubbo2.5.5+zookeeper3.4.9的服务搭建
标签:reference 启动 java color 用户名 img admin swagger odi
原文地址:http://www.cnblogs.com/hiver/p/7521522.html