Dubbo入门Demo
了解了Dubbo以后,自然要搭建一个简单的Demo实现。本文采用Dubbo与Zookeeper、Spring框架的整合。
主要是以下几个步骤:
1. 安装Zookeeper,启动;
2. 创建MAVEN项目,构建Dubbo+Zookeeper+Spring实现的简单Demo;
3. 安装Dubbo-admin,实现监控。
1 Zookeeper介绍与安装
下载安装包:http://www-eu.apache.org/dist/zookeeper/zookeeper-3.4.12/
具体的安装过程可以参考:https://blog.csdn.net/tlk20071/article/details/52028945
安装完成后,进入到bin目录,并且启动zkServer.cmd,这个脚本中会启动一个java进程:
(注:需要先启动zookeeper后,后续dubbo demo代码运行才能使用zookeeper注册中心的功能
2,创建demo项目。具体的项目 git地址为:https://github.com/wenjieyatou/DatatablesDemo
具体分析见:
https://blog.csdn.net/noaman_wgs/article/details/70214612/
3,具体的项目结构为:
项目结构:
主要分三大模块:
dubbo-api : 存放公共接口;
dubbo-consumer : 调用远程服务;
dubbo-provider : 提供远程服务。
其中父模块的pom.xml为:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>wenjie</groupId> <artifactId>dubbo</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <modules> <module>dubbo-api</module> <module>dubbo-provider</module> <module>dubbo-consumer</module> </modules> <name>DubboDemo Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <!-- spring版本号 --> <spring.version>4.2.5.RELEASE</spring.version> <!-- mybatis版本号 --> <mybatis.version>3.2.8</mybatis.version> <!-- mysql驱动版本号 --> <mysql-driver.version>5.1.29</mysql-driver.version> <!-- log4j日志包版本号 --> <slf4j.version>1.7.18</slf4j.version> <log4j.version>1.2.17</log4j.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <!-- 添加jstl依赖 --> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>7.0</version> </dependency> <!-- 添加junit4依赖 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <!-- 指定范围,在测试时才会加载 --> <scope>test</scope> </dependency> <!-- 添加spring核心依赖 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> </dependency> <!-- 添加mybatis依赖 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <!-- 添加mybatis/spring整合包依赖 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.2</version> </dependency> <!-- 添加mysql驱动依赖 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql-driver.version}</version> </dependency> <!-- 添加数据库连接池依赖 --> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.2.2</version> </dependency> <!-- 添加fastjson --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.22</version> </dependency> <!-- 添加日志相关jar包 --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <!-- log end --> <!-- 映入JSON --> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.13</version> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.8.0</version> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.8.0</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.9</version> </dependency> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.2.1</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-web</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-ehcache</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>3.4.9</version> </dependency> <!-- dubbo --> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>2.5.3</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.101tec</groupId> <artifactId>zkclient</artifactId> <version>0.10</version> </dependency> </dependencies> <build> <finalName>dubbo</finalName> </build> </project>
其中provider模块中pom.xml文件为:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>dubbo</artifactId> <groupId>wenjie</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>dubbo-provider</artifactId> <dependencies> <dependency> <groupId>wenjie</groupId> <artifactId>dubbo-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </project>
log4j.xml配置为:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n" /> </layout> </appender> <root> <level value="INFO" /> <appender-ref ref="CONSOLE" /> </root> </log4j:configuration>
provider.xml配置为:
<?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-admin 或 dubbo-monitor 会显示这个名字,方便辨识--> <dubbo:application name="demotest-provider" owner="programmer" organization="dubbox"/> <!--使用 zookeeper 注册中心暴露服务,注意要先开启 zookeeper--> <dubbo:registry address="zookeeper://localhost:2181"/> <!-- 用dubbo协议在20880端口暴露服务 --> <dubbo:protocol name="dubbo" port="20880" /> <!--使用 dubbo 协议实现定义好的 api.PermissionService 接口--> <dubbo:service interface="com.wenjie.dubbo.api.DemoService" ref="demoService" protocol="dubbo" /> <!--具体实现该接口的 bean--> <bean id="demoService" class="com.wenjie.dubbo.provider.DemoServiceImpl"/> </beans>其中provider的启动函数为:
package com.wenjie.dubbo.provider; import org.springframework.context.support.ClassPathXmlApplicationContext; import java.io.IOException; /** * Created by Gongwenjie on 2018-05-09 */ public class Provider { public static void main(String[] args) throws IOException { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("provider.xml"); System.out.println(context.getDisplayName() + ": here"); context.start(); System.out.println("服务已经启动..."); System.in.read(); } }
其中provider的服务实现为:
package com.wenjie.dubbo.provider; import com.wenjie.dubbo.api.DemoService; import java.util.ArrayList; import java.util.List; /** * Created by Gongwenjie on 2018-05-09 */ public class DemoServiceImpl implements DemoService { public List<String> getPermissions(Long id) { List<String> demo = new ArrayList<String>(); demo.add(String.format("Permission_%d", id - 1)); demo.add(String.format("Permission_%d", id)); demo.add(String.format("Permission_%d", id + 1)); return demo; } }
相对应的comsumer的pom文件为:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>dubbo</artifactId> <groupId>wenjie</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>dubbo-consumer</artifactId> <dependencies> <dependency> <groupId>wenjie</groupId> <artifactId>dubbo-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </project>
comsumer的配置文件,主要是订阅。为:
<?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="demotest-consumer" owner="programmer" organization="dubbox"/> <!--向 zookeeper 订阅 provider 的地址,由 zookeeper 定时推送--> <dubbo:registry address="zookeeper://localhost:2181"/> <!--使用 dubbo 协议调用定义好的 api.PermissionService 接口--> <dubbo:reference id="permissionService" interface="com.wenjie.dubbo.api.DemoService"/> </beans>
consumer调用服务代码为:
package com.wenjie.dubbo.consumer; import com.wenjie.dubbo.api.DemoService; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Created by Gongwenjie on 2018-05-09 */ public class Consumer { public static void main(String[] args) { //测试常规服务 ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("consumer.xml"); context.start(); System.out.println("consumer start"); DemoService demoService = context.getBean(DemoService.class); System.out.println("consumer"); System.out.println(demoService.getPermissions(1L)); } }
而api模块是属于公共服务调用接口,其中pom文件为:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <parent> <artifactId>dubbo</artifactId> <groupId>wenjie</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>dubbo-api</artifactId> <packaging>war</packaging> <name>dubbo-api Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <finalName>dubbo-api</finalName> </build> </project>
服务接口的声明为:
package com.wenjie.dubbo.api; import java.util.List; /** * Created by Gongwenjie on 2018-05-09 */ public interface DemoService { List<String> getPermissions(Long id); }
以上便是重要的点的解析。下面我们将来运行项目。先确保provider已被运行后再启动consumer模块:
provider模块都有main函数,这就是入口。先启动provider的main函数,再启动consumer即可。
[09/05/18 08:39:46:046 CST] main INFO support.ClassPathXmlApplicationContext: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@244038d0: startup date [Wed May 09 20:39:46 CST 2018]; root of context hierarchy [09/05/18 08:39:47:047 CST] main INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from class path resource [provider.xml] [09/05/18 08:39:47:047 CST] main INFO logger.LoggerFactory: using logger: com.alibaba.dubbo.common.logger.log4j.Log4jLoggerAdapter [09/05/18 08:39:48:048 CST] main INFO config.AbstractConfig: [DUBBO] The service ready on spring started. service: com.wenjie.dubbo.api.DemoService, dubbo version: 2.5.3, current host: 127.0.0.1 [09/05/18 08:39:49:049 CST] main INFO config.AbstractConfig: [DUBBO] Export dubbo service com.wenjie.dubbo.api.DemoService to local registry, dubbo version: 2.5.3, current host: 127.0.0.1 [09/05/18 08:39:49:049 CST] main INFO config.AbstractConfig: [DUBBO] Export dubbo service com.wenjie.dubbo.api.DemoService to url dubbo://192.168.77.1:20880/com.wenjie.dubbo.api.DemoService?anyhost=true&application=demotest-provider&dubbo=2.5.3&interface=com.wenjie.dubbo.api.DemoService&methods=getPermissions&organization=dubbox&owner=programmer&pid=13052&side=provider×tamp=1525869589037, dubbo version: 2.5.3, current host: 127.0.0.1 [09/05/18 08:39:49:049 CST] main INFO config.AbstractConfig: [DUBBO] Register dubbo service com.wenjie.dubbo.api.DemoService url dubbo://192.168.77.1:20880/com.wenjie.dubbo.api.DemoService?anyhost=true&application=demotest-provider&dubbo=2.5.3&interface=com.wenjie.dubbo.api.DemoService&methods=getPermissions&organization=dubbox&owner=programmer&pid=13052&side=provider×tamp=1525869589037 to registry registry://localhost:2181/com.alibaba.dubbo.registry.RegistryService?application=demotest-provider&dubbo=2.5.3&organization=dubbox&owner=programmer&pid=13052®istry=zookeeper×tamp=1525869588897, dubbo version: 2.5.3, current host: 127.0.0.1 [09/05/18 08:39:49:049 CST] main INFO transport.AbstractServer: [DUBBO] Start NettyServer bind /0.0.0.0:20880, export /192.168.77.1:20880, dubbo version: 2.5.3, current host: 127.0.0.1 [09/05/18 08:39:50:050 CST] ZkClient-EventThread-20-localhost:2181 INFO zkclient.ZkEventThread: Starting ZkClient event thread. [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:host.name=HWJ8SDS5US0OKPT [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:java.version=1.8.0_66 [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:java.home=D:\Java\jdk1.8\jre [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:java.class.path=D:\Java\jdk1.8\jre\lib\charsets.jar;D:\Java\jdk1.8\jre\lib\deploy.jar;D:\Java\jdk1.8\jre\lib\ext\access-bridge-64.jar;D:\Java\jdk1.8\jre\lib\ext\cldrdata.jar;D:\Java\jdk1.8\jre\lib\ext\dnsns.jar;D:\Java\jdk1.8\jre\lib\ext\jaccess.jar;D:\Java\jdk1.8\jre\lib\ext\jfxrt.jar;D:\Java\jdk1.8\jre\lib\ext\localedata.jar;D:\Java\jdk1.8\jre\lib\ext\nashorn.jar;D:\Java\jdk1.8\jre\lib\ext\sunec.jar;D:\Java\jdk1.8\jre\lib\ext\sunjce_provider.jar;D:\Java\jdk1.8\jre\lib\ext\sunmscapi.jar;D:\Java\jdk1.8\jre\lib\ext\sunpkcs11.jar;D:\Java\jdk1.8\jre\lib\ext\zipfs.jar;D:\Java\jdk1.8\jre\lib\javaws.jar;D:\Java\jdk1.8\jre\lib\jce.jar;D:\Java\jdk1.8\jre\lib\jfr.jar;D:\Java\jdk1.8\jre\lib\jfxswt.jar;D:\Java\jdk1.8\jre\lib\jsse.jar;D:\Java\jdk1.8\jre\lib\management-agent.jar;D:\Java\jdk1.8\jre\lib\plugin.jar;D:\Java\jdk1.8\jre\lib\resources.jar;D:\Java\jdk1.8\jre\lib\rt.jar;D:\git\developwork\dubbo\dubbo-provider\target\classes;D:\git\developwork\dubbo\dubbo-api\target\classes;G:\maven\repository\jstl\jstl\1.2\jstl-1.2.jar;G:\maven\repository\javax\javaee-api\7.0\javaee-api-7.0.jar;G:\maven\repository\com\sun\mail\javax.mail\1.5.0\javax.mail-1.5.0.jar;G:\maven\repository\javax\activation\activation\1.1\activation-1.1.jar;G:\maven\repository\org\springframework\spring-core\4.2.5.RELEASE\spring-core-4.2.5.RELEASE.jar;G:\maven\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;G:\maven\repository\org\springframework\spring-web\4.2.5.RELEASE\spring-web-4.2.5.RELEASE.jar;G:\maven\repository\org\springframework\spring-beans\4.2.5.RELEASE\spring-beans-4.2.5.RELEASE.jar;G:\maven\repository\org\springframework\spring-oxm\4.2.5.RELEASE\spring-oxm-4.2.5.RELEASE.jar;G:\maven\repository\org\springframework\spring-tx\4.2.5.RELEASE\spring-tx-4.2.5.RELEASE.jar;G:\maven\repository\org\springframework\spring-jdbc\4.2.5.RELEASE\spring-jdbc-4.2.5.RELEASE.jar;G:\maven\repository\org\springframework\spring-webmvc\4.2.5.RELEASE\spring-webmvc-4.2.5.RELEASE.jar;G:\maven\repository\org\springframework\spring-expression\4.2.5.RELEASE\spring-expression-4.2.5.RELEASE.jar;G:\maven\repository\org\springframework\spring-context\4.2.5.RELEASE\spring-context-4.2.5.RELEASE.jar;G:\maven\repository\org\springframework\spring-context-support\4.2.5.RELEASE\spring-context-support-4.2.5.RELEASE.jar;G:\maven\repository\org\springframework\spring-aop\4.2.5.RELEASE\spring-aop-4.2.5.RELEASE.jar;G:\maven\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;G:\maven\repository\org\springframework\spring-test\4.2.5.RELEASE\spring-test-4.2.5.RELEASE.jar;G:\maven\repository\org\mybatis\mybatis\3.2.8\mybatis-3.2.8.jar;G:\maven\repository\org\mybatis\mybatis-spring\1.2.2\mybatis-spring-1.2.2.jar;G:\maven\repository\mysql\mysql-connector-java\5.1.29\mysql-connector-java-5.1.29.jar;G:\maven\repository\commons-dbcp\commons-dbcp\1.2.2\commons-dbcp-1.2.2.jar;G:\maven\repository\commons-pool\commons-pool\1.3\commons-pool-1.3.jar;G:\maven\repository\com\alibaba\fastjson\1.2.22\fastjson-1.2.22.jar;G:\maven\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;G:\maven\repository\org\slf4j\slf4j-api\1.7.18\slf4j-api-1.7.18.jar;G:\maven\repository\org\slf4j\slf4j-log4j12\1.7.18\slf4j-log4j12-1.7.18.jar;G:\maven\repository\org\codehaus\jackson\jackson-mapper-asl\1.9.13\jackson-mapper-asl-1.9.13.jar;G:\maven\repository\org\codehaus\jackson\jackson-core-asl\1.9.13\jackson-core-asl-1.9.13.jar;G:\maven\repository\com\fasterxml\jackson\core\jackson-core\2.8.0\jackson-core-2.8.0.jar;G:\maven\repository\com\fasterxml\jackson\core\jackson-databind\2.8.0\jackson-databind-2.8.0.jar;G:\maven\repository\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;G:\maven\repository\commons-fileupload\commons-fileupload\1.3.1\commons-fileupload-1.3.1.jar;G:\maven\repository\commons-io\commons-io\2.4\commons-io-2.4.jar;G:\maven\repository\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;G:\maven\repository\org\quartz-scheduler\quartz\2.2.1\quartz-2.2.1.jar;G:\maven\repository\c3p0\c3p0\0.9.1.1\c3p0-0.9.1.1.jar;G:\maven\repository\org\apache\shiro\shiro-core\1.3.2\shiro-core-1.3.2.jar;G:\maven\repository\commons-beanutils\commons-beanutils\1.8.3\commons-beanutils-1.8.3.jar;G:\maven\repository\org\apache\shiro\shiro-web\1.3.2\shiro-web-1.3.2.jar;G:\maven\repository\org\apache\shiro\shiro-spring\1.3.2\shiro-spring-1.3.2.jar;G:\maven\repository\org\apache\shiro\shiro-ehcache\1.3.2\shiro-ehcache-1.3.2.jar;G:\maven\repository\net\sf\ehcache\ehcache-core\2.5.3\ehcache-core-2.5.3.jar;G:\maven\repository\org\apache\zookeeper\zookeeper\3.4.9\zookeeper-3.4.9.jar;G:\maven\repository\jline\jline\0.9.94\jline-0.9.94.jar;G:\maven\repository\io\netty\netty\3.10.5.Final\netty-3.10.5.Final.jar;G:\maven\repository\com\alibaba\dubbo\2.5.3\dubbo-2.5.3.jar;G:\maven\repository\org\javassist\javassist\3.15.0-GA\javassist-3.15.0-GA.jar;G:\maven\repository\org\jboss\netty\netty\3.2.5.Final\netty-3.2.5.Final.jar;G:\maven\repository\com\101tec\zkclient\0.10\zkclient-0.10.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.3\lib\idea_rt.jar [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:java.library.path=D:\Java\jdk1.8\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;%SystemRoot;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\;D:\Java\jdk1.8\lib;G:\programsetup\apache-maven-3.2.3\bin;C:\Program Files\Git\bin;;. [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=C:\Users\ADMINI~1\AppData\Local\Temp\ [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:java.compiler=<NA> [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:os.name=Windows 7 [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:os.arch=amd64 [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:os.version=6.1 [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:user.name=Administrator [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:user.home=C:\Users\Administrator [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Client environment:user.dir=D:\git\developwork\dubbo [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.I0Itec.zkclient.ZkClient@3e84448c [09/05/18 08:39:50:050 CST] main INFO zkclient.ZkClient: Waiting for keeper state SyncConnected [09/05/18 08:39:50:050 CST] main-SendThread(0:0:0:0:0:0:0:1:2181) INFO zookeeper.ClientCnxn: Opening socket connection to server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error) [09/05/18 08:39:50:050 CST] main-SendThread(0:0:0:0:0:0:0:1:2181) INFO zookeeper.ClientCnxn: Socket connection established to 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181, initiating session [09/05/18 08:39:50:050 CST] main-SendThread(0:0:0:0:0:0:0:1:2181) INFO zookeeper.ClientCnxn: Session establishment complete on server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181, sessionid = 0x1001052f4a10000, negotiated timeout = 30000 [09/05/18 08:39:50:050 CST] main-EventThread INFO zkclient.ZkClient: zookeeper state changed (SyncConnected) [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Register: dubbo://192.168.77.1:20880/com.wenjie.dubbo.api.DemoService?anyhost=true&application=demotest-provider&dubbo=2.5.3&interface=com.wenjie.dubbo.api.DemoService&methods=getPermissions&organization=dubbox&owner=programmer&pid=13052&side=provider×tamp=1525869589037, dubbo version: 2.5.3, current host: 127.0.0.1 [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Subscribe: provider://192.168.77.1:20880/com.wenjie.dubbo.api.DemoService?anyhost=true&application=demotest-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.wenjie.dubbo.api.DemoService&methods=getPermissions&organization=dubbox&owner=programmer&pid=13052&side=provider×tamp=1525869589037, dubbo version: 2.5.3, current host: 127.0.0.1 [09/05/18 08:39:50:050 CST] main INFO zookeeper.ZookeeperRegistry: [DUBBO] Notify urls for subscribe url provider://192.168.77.1:20880/com.wenjie.dubbo.api.DemoService?anyhost=true&application=demotest-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.wenjie.dubbo.api.DemoService&methods=getPermissions&organization=dubbox&owner=programmer&pid=13052&side=provider×tamp=1525869589037, urls: [empty://192.168.77.1:20880/com.wenjie.dubbo.api.DemoService?anyhost=true&application=demotest-provider&category=configurators&check=false&dubbo=2.5.3&interface=com.wenjie.dubbo.api.DemoService&methods=getPermissions&organization=dubbox&owner=programmer&pid=13052&side=provider×tamp=1525869589037], dubbo version: 2.5.3, current host: 127.0.0.1 org.springframework.context.support.ClassPathXmlApplicationContext@244038d0: here 服务已经启动...
consumer start consumer [Permission_0, Permission_1, Permission_2]希望大家继续关注我的博客。(づ ̄ 3 ̄)づ