dubbo和zookeeper的使用

网上下载zookeeper

下载链接http://download.csdn.net/detail/u013286716/7167881

下载完成后解压到D盘或其他地方

打开conf文件夹

dubbo和zookeeper的使用_第1张图片

把文件名改成图上所示,

进入bin文件夹

dubbo和zookeeper的使用_第2张图片

运行zkServer.cmd

dubbo和zookeeper的使用_第3张图片

启动成功后,修改dubbo配置文件

xml version="1.0" encoding="UTF-8"?>
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="zookeeper://127.0.0.1:2181" check="true" subscribe="false" />

    <dubbo:protocol name="dubbo" port="20880"/>

    

    resource="spring-export.xml"/>
编写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--------
----------------------------------

运行成功

你可能感兴趣的:(java)