工程目录结构如下
新建工程
com.wl.springcloud
dubbo-zookeeper
1.0-SNAPSHOT
pom.xml
4.0.0
com.wl.springcloud
dubbo-zookeeper
1.0-SNAPSHOT
dubbo-zookeeper
http://www.example.com
UTF-8
com.wl.springcloud.dubbo.DuuboApplication
1.5.7.RELEASE
2.6.0
3.4.10
1.7.5
2.4.5
4.12
2.4.5
1.1-groovy-2.4
org.springframework.boot
spring-boot-starter-web
${spring-boot-version}
org.slf4j
slf4j-api
com.alibaba
dubbo
${dubbo-version}
org.springframework
spring-beans
org.springframework
spring-context
org.springframework
spring-web
org.apache.zookeeper
zookeeper
${zookeeper-version}
log4j
log4j
org.slf4j
slf4j-api
org.slf4j
slf4j-log4j12
org.slf4j
slf4j-api
${slf4j-api-version}
com.github.sgroschupf
zkclient
0.1
org.apache.zookeeper
zookeeper
log4j
log4j
org.codehaus.groovy
groovy-all
${groovy-all-version}
junit
junit
${junit.version}
test
org.spockframework
spock-core
${spock-core-version}
test
org.springframework.boot
spring-boot-starter-test
${spring-boot-version}
test
org.springframework.boot
spring-boot-autoconfigure
${spring-boot-version}
org.springframework.boot
spring-boot-maven-plugin
${spring-boot-version}
${MainClass}
JAR
repackage
org.apache.maven.plugins
maven-compiler-plugin
3.1
1.8
src/main/resources
**/*.*
*.*
src/main/java
**/*.*
*.*
application.properties
server.port=8090
spring.application.name=dubbo-zookeeper
#zookeeper
env.host.zookeeper=192.168.245.129
zookeeper.address=zookeeper://${env.host.zookeeper}:2181?timeout=20000
#dubbo
dubbo.port=20212
dubbo.host=127.0.0.1
dubbo.xml配置详情参考http://dubbo.apache.org/zh-cn/docs/user/references/xml/introduction.html
启动类
package com.wl.springcloud.dubbo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
/**
* Created by Administrator on 2019/3/29.
*/
@SpringBootApplication(exclude = {
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
HibernateJpaAutoConfiguration.class //不使用数据库
},scanBasePackages = "com.wl")
public class DuuboApplication {
private static final Logger logger = LoggerFactory.getLogger(DuuboApplication.class);
public static void main(String[] args) {
SpringApplication app = new SpringApplication(DuuboApplication.class);
app.setWebEnvironment(true);
app.run(args);
logger.info("application init success");
}
}
配置类加载dubbo配置
package com.wl.springcloud.dubbo.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
/**
* Created by Administrator on 2019/3/29.
*/
@Configuration
@ImportResource(locations = "classpath:dubbo/dubbo.xml")
public class DubboConfig {
}
接口(一般情况接口和微服务以及消费者是分别独立的工程,这里为了简单都放在一个工程里面)
package com.wl.springcloud.dubbo.interfaces;
/**
* Created by Administrator on 2019/3/29.
*/
public interface IUserMicroservice {
String helloWorld();
}
实现(注意Service注解为com.alibaba.dubbo.config.annotation.Service)
package com.wl.springcloud.dubbo.interfaces.impl;
import com.alibaba.dubbo.config.annotation.Service;
import com.wl.springcloud.dubbo.interfaces.IUserMicroservice;
/**
* Created by Administrator on 2019/3/29.
*/
@Service(protocol = "dubbo")
public class UserMicroservice implements IUserMicroservice {
@Override
public String helloWorld() {
return "hello world";
}
}
消费者
package com.wl.springcloud.dubbo.controller;
import com.alibaba.dubbo.config.annotation.Reference;
import com.wl.springcloud.dubbo.interfaces.IUserMicroservice;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by Administrator on 2019/3/29.
*/
@RestController
@RequestMapping("/user")
public class UserController {
@Reference
private IUserMicroservice iUserMicroservice;
@RequestMapping("/helloWorld")
public String helloWorld(){
return iUserMicroservice.helloWorld();
}
}
启动应用
"D:\Program Files\Java\jdk1.8.0_181\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:58309,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "D:\Program Files\Java\jdk1.8.0_181\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\cldrdata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jfxrt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\nashorn.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunpkcs11.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfxswt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\rt.jar;D:\workspace\wl\study\dubbo-zookeeper\target\classes;D:\maven\repo\org\springframework\boot\spring-boot-starter-web\1.5.7.RELEASE\spring-boot-starter-web-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter\1.5.7.RELEASE\spring-boot-starter-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-logging\1.5.7.RELEASE\spring-boot-starter-logging-1.5.7.RELEASE.jar;D:\maven\repo\ch\qos\logback\logback-classic\1.1.11\logback-classic-1.1.11.jar;D:\maven\repo\ch\qos\logback\logback-core\1.1.11\logback-core-1.1.11.jar;D:\maven\repo\org\slf4j\jcl-over-slf4j\1.7.25\jcl-over-slf4j-1.7.25.jar;D:\maven\repo\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;D:\maven\repo\org\slf4j\log4j-over-slf4j\1.7.25\log4j-over-slf4j-1.7.25.jar;D:\maven\repo\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-tomcat\1.5.7.RELEASE\spring-boot-starter-tomcat-1.5.7.RELEASE.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-core\8.5.20\tomcat-embed-core-8.5.20.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-el\8.5.20\tomcat-embed-el-8.5.20.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.20\tomcat-embed-websocket-8.5.20.jar;D:\maven\repo\org\hibernate\hibernate-validator\5.3.5.Final\hibernate-validator-5.3.5.Final.jar;D:\maven\repo\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;D:\maven\repo\org\jboss\logging\jboss-logging\3.3.0.Final\jboss-logging-3.3.0.Final.jar;D:\maven\repo\com\fasterxml\classmate\1.3.1\classmate-1.3.1.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-databind\2.8.10\jackson-databind-2.8.10.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-core\2.8.10\jackson-core-2.8.10.jar;D:\maven\repo\org\springframework\spring-web\4.3.11.RELEASE\spring-web-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-aop\4.3.11.RELEASE\spring-aop-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-beans\4.3.11.RELEASE\spring-beans-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-context\4.3.11.RELEASE\spring-context-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-webmvc\4.3.11.RELEASE\spring-webmvc-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-expression\4.3.11.RELEASE\spring-expression-4.3.11.RELEASE.jar;D:\maven\repo\com\alibaba\dubbo\2.6.0\dubbo-2.6.0.jar;D:\maven\repo\org\javassist\javassist\3.20.0-GA\javassist-3.20.0-GA.jar;D:\maven\repo\org\jboss\netty\netty\3.2.5.Final\netty-3.2.5.Final.jar;D:\maven\repo\org\apache\zookeeper\zookeeper\3.4.10\zookeeper-3.4.10.jar;D:\maven\repo\jline\jline\0.9.94\jline-0.9.94.jar;D:\maven\repo\io\netty\netty\3.10.5.Final\netty-3.10.5.Final.jar;D:\maven\repo\org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar;D:\maven\repo\com\github\sgroschupf\zkclient\0.1\zkclient-0.1.jar;D:\maven\repo\org\codehaus\groovy\groovy-all\2.4.5\groovy-all-2.4.5.jar;D:\maven\repo\org\springframework\spring-core\4.3.11.RELEASE\spring-core-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-autoconfigure\1.5.7.RELEASE\spring-boot-autoconfigure-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot\1.5.7.RELEASE\spring-boot-1.5.7.RELEASE.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2017.1.6\lib\idea_rt.jar" com.wl.springcloud.dubbo.DuuboApplication
Connected to the target VM, address: '127.0.0.1:58309', transport: 'socket'
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.7.RELEASE)
2019-03-29 21:12:31.957 INFO 8544 --- [ main] c.wl.springcloud.dubbo.DuuboApplication : Starting DuuboApplication on wl with PID 8544 (D:\workspace\wl\study\dubbo-zookeeper\target\classes started by Administrator in D:\workspace\wl\study\dubbo-zookeeper)
2019-03-29 21:12:31.960 INFO 8544 --- [ main] c.wl.springcloud.dubbo.DuuboApplication : No active profile set, falling back to default profiles: default
2019-03-29 21:12:32.309 INFO 8544 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@696da30b: startup date [Fri Mar 29 21:12:32 CST 2019]; root of context hierarchy
2019-03-29 21:12:32.621 INFO 8544 --- [ main] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from class path resource [dubbo/dubbo.xml]
2019-03-29 21:12:32.703 INFO 8544 --- [ main] c.a.dubbo.common.logger.LoggerFactory : using logger: com.alibaba.dubbo.common.logger.log4j.Log4jLoggerAdapter
2019-03-29 21:12:33.360 INFO 8544 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8090 (http)
2019-03-29 21:12:33.372 INFO 8544 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-03-29 21:12:33.373 INFO 8544 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.20
2019-03-29 21:12:33.476 INFO 8544 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-03-29 21:12:33.477 INFO 8544 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1171 ms
2019-03-29 21:12:33.600 INFO 8544 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2019-03-29 21:12:33.604 INFO 8544 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-29 21:12:33.605 INFO 8544 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-03-29 21:12:33.605 INFO 8544 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-03-29 21:12:33.605 INFO 8544 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2019-03-29 21:12:33.820 INFO 8544 --- [ main] c.a.d.r.zookeeper.ZookeeperRegistry : [DUBBO] Load registry store file C:\Users\Administrator\.dubbo\dubbo-registry-dubbo-zooleeper-192.168.245.129:2181.cache, data: {com.wl.springcloud.dubbo.interfaces.IUserMicroservice:1.0.0=empty://192.168.245.1/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?application=dubbo-zooleeper&category=configurators&default.check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=10580&side=consumer×tamp=1553865081505 empty://192.168.245.1/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?application=dubbo-zooleeper&category=routers&default.check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=10580&side=consumer×tamp=1553865081505 dubbo://192.168.245.1:20212/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?anyhost=true&application=dubbo-zookeeper&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&generic=false&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=10580&side=provider×tamp=1553865092463, com.alibaba.dubbo.monitor.MonitorService=empty:///com.alibaba.dubbo.monitor.MonitorService?category=configurators&dubbo=2.6.0&interface=com.alibaba.dubbo.monitor.MonitorService&pid=10580×tamp=1553865092472 empty:///com.alibaba.dubbo.monitor.MonitorService?category=routers&dubbo=2.6.0&interface=com.alibaba.dubbo.monitor.MonitorService&pid=10580×tamp=1553865092472 empty:///com.alibaba.dubbo.monitor.MonitorService?category=providers&dubbo=2.6.0&interface=com.alibaba.dubbo.monitor.MonitorService&pid=10580×tamp=1553865092472}, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:33.828 INFO 8544 --- [ main] c.a.d.common.concurrent.ExecutionList : [DUBBO] Executor for listenablefuture is null, will use default executor!, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:33.834 INFO 8544 --- [68.245.129:2181] org.I0Itec.zkclient.ZkEventThread : Starting ZkClient event thread.
2019-03-29 21:12:42.852 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
2019-03-29 21:12:42.853 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:host.name=wl
2019-03-29 21:12:42.853 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:java.version=1.8.0_181
2019-03-29 21:12:42.853 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:java.vendor=Oracle Corporation
2019-03-29 21:12:42.853 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:java.home=D:\Program Files\Java\jdk1.8.0_181\jre
2019-03-29 21:12:42.853 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:java.class.path=D:\Program Files\Java\jdk1.8.0_181\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\cldrdata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jfxrt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\nashorn.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunpkcs11.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfxswt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\rt.jar;D:\workspace\wl\study\dubbo-zookeeper\target\classes;D:\maven\repo\org\springframework\boot\spring-boot-starter-web\1.5.7.RELEASE\spring-boot-starter-web-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter\1.5.7.RELEASE\spring-boot-starter-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-logging\1.5.7.RELEASE\spring-boot-starter-logging-1.5.7.RELEASE.jar;D:\maven\repo\ch\qos\logback\logback-classic\1.1.11\logback-classic-1.1.11.jar;D:\maven\repo\ch\qos\logback\logback-core\1.1.11\logback-core-1.1.11.jar;D:\maven\repo\org\slf4j\jcl-over-slf4j\1.7.25\jcl-over-slf4j-1.7.25.jar;D:\maven\repo\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;D:\maven\repo\org\slf4j\log4j-over-slf4j\1.7.25\log4j-over-slf4j-1.7.25.jar;D:\maven\repo\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;D:\maven\repo\org\springframework\boot\spring-boot-starter-tomcat\1.5.7.RELEASE\spring-boot-starter-tomcat-1.5.7.RELEASE.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-core\8.5.20\tomcat-embed-core-8.5.20.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-el\8.5.20\tomcat-embed-el-8.5.20.jar;D:\maven\repo\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.20\tomcat-embed-websocket-8.5.20.jar;D:\maven\repo\org\hibernate\hibernate-validator\5.3.5.Final\hibernate-validator-5.3.5.Final.jar;D:\maven\repo\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;D:\maven\repo\org\jboss\logging\jboss-logging\3.3.0.Final\jboss-logging-3.3.0.Final.jar;D:\maven\repo\com\fasterxml\classmate\1.3.1\classmate-1.3.1.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-databind\2.8.10\jackson-databind-2.8.10.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;D:\maven\repo\com\fasterxml\jackson\core\jackson-core\2.8.10\jackson-core-2.8.10.jar;D:\maven\repo\org\springframework\spring-web\4.3.11.RELEASE\spring-web-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-aop\4.3.11.RELEASE\spring-aop-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-beans\4.3.11.RELEASE\spring-beans-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-context\4.3.11.RELEASE\spring-context-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-webmvc\4.3.11.RELEASE\spring-webmvc-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\spring-expression\4.3.11.RELEASE\spring-expression-4.3.11.RELEASE.jar;D:\maven\repo\com\alibaba\dubbo\2.6.0\dubbo-2.6.0.jar;D:\maven\repo\org\javassist\javassist\3.20.0-GA\javassist-3.20.0-GA.jar;D:\maven\repo\org\jboss\netty\netty\3.2.5.Final\netty-3.2.5.Final.jar;D:\maven\repo\org\apache\zookeeper\zookeeper\3.4.10\zookeeper-3.4.10.jar;D:\maven\repo\jline\jline\0.9.94\jline-0.9.94.jar;D:\maven\repo\io\netty\netty\3.10.5.Final\netty-3.10.5.Final.jar;D:\maven\repo\org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar;D:\maven\repo\com\github\sgroschupf\zkclient\0.1\zkclient-0.1.jar;D:\maven\repo\org\codehaus\groovy\groovy-all\2.4.5\groovy-all-2.4.5.jar;D:\maven\repo\org\springframework\spring-core\4.3.11.RELEASE\spring-core-4.3.11.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot-autoconfigure\1.5.7.RELEASE\spring-boot-autoconfigure-1.5.7.RELEASE.jar;D:\maven\repo\org\springframework\boot\spring-boot\1.5.7.RELEASE\spring-boot-1.5.7.RELEASE.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2017.1.6\lib\idea_rt.jar
2019-03-29 21:12:42.857 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:java.library.path=D:\Program Files\Java\jdk1.8.0_181\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\Program Files\Java\jdk1.8.0_181\bin;D:\maven\apache-maven-3.5.4\bin;D:\apache-tomcat-8.5.32\bin;D:\gradle-3.5\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\MySQL\MySQL Utilities 1.6\;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;D:\Go\bin;D:\MinGW\bin;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;;c:\Users\Administrator\AppData\Local\Programs\Fiddler;.
2019-03-29 21:12:42.857 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:java.io.tmpdir=C:\Users\ADMINI~1\AppData\Local\Temp\
2019-03-29 21:12:42.857 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:java.compiler=
2019-03-29 21:12:42.857 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:os.name=Windows 10
2019-03-29 21:12:42.857 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:os.arch=amd64
2019-03-29 21:12:42.858 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:os.version=10.0
2019-03-29 21:12:42.858 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:user.name=Administrator
2019-03-29 21:12:42.858 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:user.home=C:\Users\Administrator
2019-03-29 21:12:42.858 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Client environment:user.dir=D:\workspace\wl\study\dubbo-zookeeper
2019-03-29 21:12:42.861 INFO 8544 --- [clientConnector] org.apache.zookeeper.ZooKeeper : Initiating client connection, connectString=192.168.245.129:2181 sessionTimeout=30000 watcher=org.I0Itec.zkclient.ZkClient@6153d25
2019-03-29 21:12:42.938 INFO 8544 --- [8.245.129:2181)] org.apache.zookeeper.ClientCnxn : Opening socket connection to server 192.168.245.129/192.168.245.129:2181. Will not attempt to authenticate using SASL (unknown error)
2019-03-29 21:12:42.939 INFO 8544 --- [8.245.129:2181)] org.apache.zookeeper.ClientCnxn : Socket connection established to 192.168.245.129/192.168.245.129:2181, initiating session
2019-03-29 21:12:42.945 INFO 8544 --- [8.245.129:2181)] org.apache.zookeeper.ClientCnxn : Session establishment complete on server 192.168.245.129/192.168.245.129:2181, sessionid = 0x169c931a3900009, negotiated timeout = 30000
2019-03-29 21:12:42.946 INFO 8544 --- [tor-EventThread] org.I0Itec.zkclient.ZkClient : zookeeper state changed (SyncConnected)
2019-03-29 21:12:42.960 INFO 8544 --- [ main] c.a.d.r.zookeeper.ZookeeperRegistry : [DUBBO] Register: consumer://192.168.245.1/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?application=dubbo-zooleeper&category=consumers&check=false&default.check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=consumer×tamp=1553865153783, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:42.969 INFO 8544 --- [ main] c.a.d.r.zookeeper.ZookeeperRegistry : [DUBBO] Subscribe: consumer://192.168.245.1/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?application=dubbo-zooleeper&category=providers,configurators,routers&default.check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=consumer×tamp=1553865153783, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:42.983 INFO 8544 --- [ main] c.a.d.r.zookeeper.ZookeeperRegistry : [DUBBO] Notify urls for subscribe url consumer://192.168.245.1/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?application=dubbo-zooleeper&category=providers,configurators,routers&default.check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=consumer×tamp=1553865153783, urls: [empty://192.168.245.1/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?application=dubbo-zooleeper&category=providers&default.check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=consumer×tamp=1553865153783, empty://192.168.245.1/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?application=dubbo-zooleeper&category=configurators&default.check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=consumer×tamp=1553865153783, empty://192.168.245.1/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?application=dubbo-zooleeper&category=routers&default.check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=consumer×tamp=1553865153783], dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:42.986 INFO 8544 --- [ main] com.alibaba.dubbo.config.AbstractConfig : [DUBBO] Refer dubbo service com.wl.springcloud.dubbo.interfaces.IUserMicroservice from url zookeeper://192.168.245.129:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-zooleeper&default.check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544®ister.ip=192.168.245.1&side=consumer×tamp=1553865153783, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:43.200 INFO 8544 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@696da30b: startup date [Fri Mar 29 21:12:32 CST 2019]; root of context hierarchy
2019-03-29 21:12:43.260 INFO 8544 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/user/helloWorld]}" onto public java.lang.String com.wl.springcloud.dubbo.controller.UserController.helloWorld()
2019-03-29 21:12:43.263 INFO 8544 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-03-29 21:12:43.263 INFO 8544 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-03-29 21:12:43.292 INFO 8544 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-29 21:12:43.292 INFO 8544 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-29 21:12:43.321 INFO 8544 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-29 21:12:43.672 INFO 8544 --- [ main] com.alibaba.dubbo.config.AbstractConfig : [DUBBO] Export dubbo service com.wl.springcloud.dubbo.interfaces.IUserMicroservice to local registry, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:43.673 INFO 8544 --- [ main] com.alibaba.dubbo.config.AbstractConfig : [DUBBO] Export dubbo service com.wl.springcloud.dubbo.interfaces.IUserMicroservice to url dubbo://192.168.245.1:20212/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?anyhost=true&application=dubbo-zooleeper&bind.ip=192.168.245.1&bind.port=20212&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&generic=false&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=provider×tamp=1553865163631, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:43.673 INFO 8544 --- [ main] com.alibaba.dubbo.config.AbstractConfig : [DUBBO] Register dubbo service com.wl.springcloud.dubbo.interfaces.IUserMicroservice url dubbo://192.168.245.1:20212/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?anyhost=true&application=dubbo-zooleeper&bind.ip=192.168.245.1&bind.port=20212&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&generic=false&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&monitor=dubbo%3A%2F%2F192.168.245.129%3A2181%2Fcom.alibaba.dubbo.registry.RegistryService%3Fapplication%3Ddubbo-zooleeper%26dubbo%3D2.6.0%26pid%3D8544%26protocol%3Dregistry%26refer%3Ddubbo%253D2.6.0%2526interface%253Dcom.alibaba.dubbo.monitor.MonitorService%2526pid%253D8544%2526timestamp%253D1553865163673%26registry%3Dzookeeper%26timeout%3D20000%26timestamp%3D1553865163630&pid=8544&side=provider×tamp=1553865163631 to registry registry://192.168.245.129:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-zooleeper&dubbo=2.6.0&pid=8544®istry=zookeeper&timeout=20000×tamp=1553865163630, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:43.748 INFO 8544 --- [ main] c.a.d.remoting.transport.AbstractServer : [DUBBO] Start NettyServer bind /0.0.0.0:20212, export /192.168.245.1:20212, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:43.750 INFO 8544 --- [ main] c.a.d.r.zookeeper.ZookeeperRegistry : [DUBBO] Register: dubbo://192.168.245.1:20212/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?anyhost=true&application=dubbo-zooleeper&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&generic=false&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=provider×tamp=1553865163631, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:43.754 INFO 8544 --- [ main] c.a.d.r.zookeeper.ZookeeperRegistry : [DUBBO] Subscribe: provider://192.168.245.1:20212/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?anyhost=true&application=dubbo-zooleeper&category=configurators&check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&generic=false&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=provider×tamp=1553865163631, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:43.755 INFO 8544 --- [68.245.129:2181] c.a.d.r.zookeeper.ZookeeperRegistry : [DUBBO] Notify urls for subscribe url consumer://192.168.245.1/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?application=dubbo-zooleeper&category=providers,configurators,routers&default.check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=consumer×tamp=1553865153783, urls: [dubbo://192.168.245.1:20212/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?anyhost=true&application=dubbo-zooleeper&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&generic=false&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=provider×tamp=1553865163631], dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:43.760 INFO 8544 --- [ main] c.a.d.r.zookeeper.ZookeeperRegistry : [DUBBO] Notify urls for subscribe url provider://192.168.245.1:20212/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?anyhost=true&application=dubbo-zooleeper&category=configurators&check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&generic=false&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=provider×tamp=1553865163631, urls: [empty://192.168.245.1:20212/com.wl.springcloud.dubbo.interfaces.IUserMicroservice?anyhost=true&application=dubbo-zooleeper&category=configurators&check=false&default.retries=0&default.timeout=3000&default.version=1.0.0&dubbo=2.6.0&generic=false&interface=com.wl.springcloud.dubbo.interfaces.IUserMicroservice&methods=helloWorld&pid=8544&side=provider×tamp=1553865163631], dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:43.782 INFO 8544 --- [68.245.129:2181] c.a.d.remoting.transport.AbstractClient : [DUBBO] Successed connect to server /192.168.245.1:20212 from NettyClient 192.168.245.1 using dubbo version 2.6.0, channel is NettyChannel [channel=[id: 0x198d7f7d, /192.168.245.1:58327 => /192.168.245.1:20212]], dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:43.782 INFO 8544 --- [68.245.129:2181] c.a.d.remoting.transport.AbstractClient : [DUBBO] Start NettyClient wl/192.168.245.1 connect to the server /192.168.245.1:20212, dubbo version: 2.6.0, current host: 192.168.245.1
2019-03-29 21:12:43.860 INFO 8544 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2019-03-29 21:12:43.896 INFO 8544 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8090 (http)
2019-03-29 21:12:43.901 INFO 8544 --- [ main] c.wl.springcloud.dubbo.DuuboApplication : Started DuuboApplication in 12.196 seconds (JVM running for 12.51)
2019-03-29 21:12:43.901 INFO 8544 --- [ main] c.wl.springcloud.dubbo.DuuboApplication : application init success
访问dubbo-admin
浏览器输入http://localhost:8090/user/helloWorld
查看zookeeper注册信息(去掉了其他的dubbo接口)
root@ubuntu:/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin# ./zkCli.sh
Connecting to localhost:2181
2019-03-29 21:16:33,693 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
2019-03-29 21:16:33,697 [myid:] - INFO [main:Environment@100] - Client environment:host.name=ubuntu
2019-03-29 21:16:33,697 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_121
2019-03-29 21:16:33,699 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2019-03-29 21:16:33,699 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/java/jdk1.8.0_121/jre
2019-03-29 21:16:33,700 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin/../build/classes:/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin/../build/lib/*.jar:/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin/../lib/netty-3.10.5.Final.jar:/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin/../lib/log4j-1.2.16.jar:/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin/../lib/jline-0.9.94.jar:/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin/../zookeeper-3.4.10.jar:/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin/../src/java/lib/*.jar:/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin/../conf:.:/usr/jdk1.8/lib/
2019-03-29 21:16:33,700 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2019-03-29 21:16:33,700 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2019-03-29 21:16:33,700 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=
2019-03-29 21:16:33,701 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2019-03-29 21:16:33,701 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2019-03-29 21:16:33,701 [myid:] - INFO [main:Environment@100] - Client environment:os.version=4.4.0-31-generic
2019-03-29 21:16:33,701 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
2019-03-29 21:16:33,702 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
2019-03-29 21:16:33,702 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/usr/local/dubbo/zookeeper/zookeeper-3.4.10/bin
2019-03-29 21:16:33,704 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@506c589e
2019-03-29 21:16:33,723 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
Welcome to ZooKeeper!
JLine support is enabled
2019-03-29 21:16:33,893 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2019-03-29 21:16:33,912 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x169c931a390000b, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] ls /
[dubbo, services, zookeeper]
[zk: localhost:2181(CONNECTED) 1] ls /dubbo
[com.wl.springcloud.dubbo.interfaces.IUserMicroservice]
[zk: localhost:2181(CONNECTED) 2]