网上下载zookeeper
下载链接http://download.csdn.net/detail/u013286716/7167881
下载完成后解压到D盘或其他地方
打开conf文件夹
把文件名改成图上所示,
进入bin文件夹
运行zkServer.cmd
启动成功后,修改dubbo配置文件
<?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="itfarm-provider"/> <!--本地启动--> <!--<dubbo:registry address="multicast://224.5.6.7:1234" />--> <!--zookeeper启动--> <dubbo:registry address="zookeeper://127.0.0.1:2181" check="true" subscribe="false" /> <dubbo:protocol name="dubbo" port="20880"/> <!--1)register是否向此注册中心注册服务,如果设为false,将只订阅,不注册。 2)check注册中心不存在时,是否报错。 3)subscribe是否向此注册中心订阅服务,如果设为false,将只注册,不订阅。 4)timeout注册中心请求超时时间(毫秒)。 5)address可以Zookeeper集群配置,地址可以多个以逗号隔开等。 dubbo:service标签的一些属性说明: 1)interface服务接口的路径 2)ref引用对应的实现类的Bean的ID 3)registry向指定注册中心注册,在多个注册中心时使用,值为<dubbo:registry>的id属性,多个注册中心ID用逗号分隔,如果不想将该服务注册到任何registry,可将值设为N/A 4)register 默认true ,该协议的服务是否注册到注册中心。--> <import resource="spring-export.xml"/> </beans>编写main方法运行dubbo
public class App { public static void main( String[] args ) throws IOException { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("dubbo.xml"); System.out.println("----------------------------------"); System.out.println("---------dubbo run success--------"); System.out.println("----------------------------------"); System.in.read(); } }2016-08-22 18:29:21 [ main:10826 ] - [ INFO ] [DUBBO] Register: dubbo://10.1.18.13:20880/com.tc.itfarm.service.UserService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.UserService&methods=update,selectByUsername,selectUserByPage,save,select,updateBySelective,delete,insert,selectAll&pid=7900&side=provider×tamp=1471861761185, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:10918 ] - [ INFO ] [DUBBO] Subscribe: provider://10.1.18.13:20880/com.tc.itfarm.service.UserService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.UserService&methods=update,selectByUsername,selectUserByPage,save,select,updateBySelective,delete,insert,selectAll&pid=7900&side=provider×tamp=1471861761185, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:10988 ] - [ INFO ] [DUBBO] Notify urls for subscribe url provider://10.1.18.13:20880/com.tc.itfarm.service.UserService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.UserService&methods=update,selectByUsername,selectUserByPage,save,select,updateBySelective,delete,insert,selectAll&pid=7900&side=provider×tamp=1471861761185, urls: [empty://10.1.18.13:20880/com.tc.itfarm.service.UserService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.UserService&methods=update,selectByUsername,selectUserByPage,save,select,updateBySelective,delete,insert,selectAll&pid=7900&side=provider×tamp=1471861761185], dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:10989 ] - [ INFO ] [DUBBO] The service ready on spring started. service: com.tc.itfarm.service.RoleService, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11013 ] - [ INFO ] [DUBBO] Export dubbo service com.tc.itfarm.service.RoleService to local registry, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11013 ] - [ INFO ] [DUBBO] Export dubbo service com.tc.itfarm.service.RoleService to url dubbo://10.1.18.13:20880/com.tc.itfarm.service.RoleService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.RoleService&methods=update,save,select,updateBySelective,delete,insert,selectByPageList,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761373, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11013 ] - [ INFO ] [DUBBO] Register dubbo service com.tc.itfarm.service.RoleService url dubbo://10.1.18.13:20880/com.tc.itfarm.service.RoleService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.RoleService&methods=update,save,select,updateBySelective,delete,insert,selectByPageList,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761373 to registry registry://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=itfarm-provider&check=true&dubbo=2.5.3&pid=7900®istry=zookeeper&subscribe=false×tamp=1471861761372, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11015 ] - [ INFO ] [DUBBO] Register: dubbo://10.1.18.13:20880/com.tc.itfarm.service.RoleService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.RoleService&methods=update,save,select,updateBySelective,delete,insert,selectByPageList,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761373, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11133 ] - [ INFO ] [DUBBO] Subscribe: provider://10.1.18.13:20880/com.tc.itfarm.service.RoleService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.RoleService&methods=update,save,select,updateBySelective,delete,insert,selectByPageList,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761373, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11196 ] - [ INFO ] [DUBBO] Notify urls for subscribe url provider://10.1.18.13:20880/com.tc.itfarm.service.RoleService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.RoleService&methods=update,save,select,updateBySelective,delete,insert,selectByPageList,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761373, urls: [empty://10.1.18.13:20880/com.tc.itfarm.service.RoleService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.RoleService&methods=update,save,select,updateBySelective,delete,insert,selectByPageList,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761373], dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11197 ] - [ INFO ] [DUBBO] The service ready on spring started. service: com.tc.itfarm.service.UserRoleService, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11235 ] - [ INFO ] [DUBBO] Export dubbo service com.tc.itfarm.service.UserRoleService to local registry, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11235 ] - [ INFO ] [DUBBO] Export dubbo service com.tc.itfarm.service.UserRoleService to url dubbo://10.1.18.13:20880/com.tc.itfarm.service.UserRoleService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.UserRoleService&methods=update,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761603, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11235 ] - [ INFO ] [DUBBO] Register dubbo service com.tc.itfarm.service.UserRoleService url dubbo://10.1.18.13:20880/com.tc.itfarm.service.UserRoleService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.UserRoleService&methods=update,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761603 to registry registry://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=itfarm-provider&check=true&dubbo=2.5.3&pid=7900®istry=zookeeper&subscribe=false×tamp=1471861761602, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11237 ] - [ INFO ] [DUBBO] Register: dubbo://10.1.18.13:20880/com.tc.itfarm.service.UserRoleService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.UserRoleService&methods=update,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761603, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11402 ] - [ INFO ] [DUBBO] Subscribe: provider://10.1.18.13:20880/com.tc.itfarm.service.UserRoleService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.UserRoleService&methods=update,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761603, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11468 ] - [ INFO ] [DUBBO] Notify urls for subscribe url provider://10.1.18.13:20880/com.tc.itfarm.service.UserRoleService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.UserRoleService&methods=update,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761603, urls: [empty://10.1.18.13:20880/com.tc.itfarm.service.UserRoleService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.UserRoleService&methods=update,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861761603], dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11470 ] - [ INFO ] [DUBBO] The service ready on spring started. service: com.tc.itfarm.service.PrivilegeService, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11496 ] - [ INFO ] [DUBBO] Export dubbo service com.tc.itfarm.service.PrivilegeService to local registry, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11496 ] - [ INFO ] [DUBBO] Export dubbo service com.tc.itfarm.service.PrivilegeService to url dubbo://10.1.18.13:20880/com.tc.itfarm.service.PrivilegeService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.PrivilegeService&methods=update,selectAllTree,save,select,selectAll,selectByRoleId,updateBySelective,delete,insert,selectByPageList,selectPrivilegetree&pid=7900&side=provider×tamp=1471861761860, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11496 ] - [ INFO ] [DUBBO] Register dubbo service com.tc.itfarm.service.PrivilegeService url dubbo://10.1.18.13:20880/com.tc.itfarm.service.PrivilegeService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.PrivilegeService&methods=update,selectAllTree,save,select,selectAll,selectByRoleId,updateBySelective,delete,insert,selectByPageList,selectPrivilegetree&pid=7900&side=provider×tamp=1471861761860 to registry registry://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=itfarm-provider&check=true&dubbo=2.5.3&pid=7900®istry=zookeeper&subscribe=false×tamp=1471861761860, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:21 [ main:11497 ] - [ INFO ] [DUBBO] Register: dubbo://10.1.18.13:20880/com.tc.itfarm.service.PrivilegeService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.PrivilegeService&methods=update,selectAllTree,save,select,selectAll,selectByRoleId,updateBySelective,delete,insert,selectByPageList,selectPrivilegetree&pid=7900&side=provider×tamp=1471861761860, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:22 [ main:11860 ] - [ INFO ] [DUBBO] Subscribe: provider://10.1.18.13:20880/com.tc.itfarm.service.PrivilegeService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.PrivilegeService&methods=update,selectAllTree,save,select,selectAll,selectByRoleId,updateBySelective,delete,insert,selectByPageList,selectPrivilegetree&pid=7900&side=provider×tamp=1471861761860, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:22 [ main:11929 ] - [ INFO ] [DUBBO] Notify urls for subscribe url provider://10.1.18.13:20880/com.tc.itfarm.service.PrivilegeService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.PrivilegeService&methods=update,selectAllTree,save,select,selectAll,selectByRoleId,updateBySelective,delete,insert,selectByPageList,selectPrivilegetree&pid=7900&side=provider×tamp=1471861761860, urls: [empty://10.1.18.13:20880/com.tc.itfarm.service.PrivilegeService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.PrivilegeService&methods=update,selectAllTree,save,select,selectAll,selectByRoleId,updateBySelective,delete,insert,selectByPageList,selectPrivilegetree&pid=7900&side=provider×tamp=1471861761860], dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:22 [ main:11931 ] - [ INFO ] [DUBBO] The service ready on spring started. service: com.tc.itfarm.service.RolePrivilegeService, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:22 [ main:11980 ] - [ INFO ] [DUBBO] Export dubbo service com.tc.itfarm.service.RolePrivilegeService to local registry, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:22 [ main:11980 ] - [ INFO ] [DUBBO] Export dubbo service com.tc.itfarm.service.RolePrivilegeService to url dubbo://10.1.18.13:20880/com.tc.itfarm.service.RolePrivilegeService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.RolePrivilegeService&methods=update,selectByRoleId,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861762321, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:22 [ main:11980 ] - [ INFO ] [DUBBO] Register dubbo service com.tc.itfarm.service.RolePrivilegeService url dubbo://10.1.18.13:20880/com.tc.itfarm.service.RolePrivilegeService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.RolePrivilegeService&methods=update,selectByRoleId,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861762321 to registry registry://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=itfarm-provider&check=true&dubbo=2.5.3&pid=7900®istry=zookeeper&subscribe=false×tamp=1471861762320, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:22 [ main:11982 ] - [ INFO ] [DUBBO] Register: dubbo://10.1.18.13:20880/com.tc.itfarm.service.RolePrivilegeService?anyhost=true&application=itfarm-provider&dubbo=2.5.3&interface=com.tc.itfarm.service.RolePrivilegeService&methods=update,selectByRoleId,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861762321, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:22 [ main:12099 ] - [ INFO ] [DUBBO] Subscribe: provider://10.1.18.13:20880/com.tc.itfarm.service.RolePrivilegeService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.RolePrivilegeService&methods=update,selectByRoleId,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861762321, dubbo version: 2.5.3, current host: 127.0.0.1
2016-08-22 18:29:22 [ main:12166 ] - [ INFO ] [DUBBO] Notify urls for subscribe url provider://10.1.18.13:20880/com.tc.itfarm.service.RolePrivilegeService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.RolePrivilegeService&methods=update,selectByRoleId,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861762321, urls: [empty://10.1.18.13:20880/com.tc.itfarm.service.RolePrivilegeService?anyhost=true&application=itfarm-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.tc.itfarm.service.RolePrivilegeService&methods=update,selectByRoleId,select,updateBySelective,delete,insert,selectAll,selectByUserId&pid=7900&side=provider×tamp=1471861762321], dubbo version: 2.5.3, current host: 127.0.0.1
----------------------------------
---------dubbo run success--------
----------------------------------
运行成功