因为 dubbox 并没有发布到maven中央仓库仓库中,所以需要我们自己到官网下载,自己编译,install 到本地。

1. 首先安装git客户端工具 TortoiseGit, 然后使用它将 dubbox 从官网github地址:https://github.com/dangdangdotcom/dubbox clone到本地:

2. 使用mvn 编译:

在cmd 中执行:

E:\Java_book\dubbo\dubbox\dubbox>mvn install -Dmaven.test.skip=true

一般要几分钟到十几分钟,第一次有可能编译失败,失败时,重新执行命令就行,编译成功如下:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] dubbo-parent ....................................... SUCCESS [ 0.644 s]
[INFO] Hessian Lite(Alibaba embed version) ................ SUCCESS [ 0.982 s]
[INFO] dubbo-common ....................................... SUCCESS [ 0.744 s]
[INFO] dubbo-container .................................... SUCCESS [ 0.013 s]
[INFO] dubbo-container-api ................................ SUCCESS [ 0.127 s]
[INFO] dubbo-container-spring ............................. SUCCESS [ 0.100 s]
[INFO] dubbo-container-javaconfig ......................... SUCCESS [ 0.068 s]
[INFO] dubbo-container-jetty .............................. SUCCESS [ 0.062 s]
[INFO] dubbo-container-log4j .............................. SUCCESS [ 0.072 s]
[INFO] dubbo-container-logback ............................ SUCCESS [ 0.081 s]
[INFO] dubbo-remoting ..................................... SUCCESS [ 0.008 s]
[INFO] dubbo-remoting-api ................................. SUCCESS [ 0.317 s]
[INFO] dubbo-remoting-netty ............................... SUCCESS [ 0.105 s]
[INFO] dubbo-remoting-mina ................................ SUCCESS [ 0.086 s]
[INFO] dubbo-remoting-grizzly ............................. SUCCESS [ 0.092 s]
[INFO] dubbo-remoting-p2p ................................. SUCCESS [ 0.120 s]
[INFO] dubbo-remoting-http ................................ SUCCESS [ 0.097 s]
[INFO] dubbo-remoting-zookeeper ........................... SUCCESS [ 0.121 s]
[INFO] dubbo-rpc .......................................... SUCCESS [ 0.011 s]
[INFO] dubbo-rpc-api ...................................... SUCCESS [ 0.233 s]
[INFO] dubbo-rpc-default .................................. SUCCESS [ 0.157 s]
[INFO] dubbo-rpc-injvm .................................... SUCCESS [ 0.064 s]
[INFO] dubbo-rpc-rmi ...................................... SUCCESS [ 0.071 s]
[INFO] dubbo-rpc-hessian .................................. SUCCESS [ 0.098 s]
[INFO] dubbo-rpc-http ..................................... SUCCESS [ 0.079 s]
[INFO] dubbo-rpc-webservice ............................... SUCCESS [ 0.145 s]
[INFO] dubbo-cluster ...................................... SUCCESS [ 0.226 s]
[INFO] dubbo-registry ..................................... SUCCESS [ 0.008 s]
[INFO] dubbo-registry-api ................................. SUCCESS [ 0.109 s]
[INFO] dubbo-monitor ...................................... SUCCESS [ 0.009 s]
[INFO] dubbo-monitor-api .................................. SUCCESS [ 0.064 s]
[INFO] dubbo-filter ....................................... SUCCESS [ 0.009 s]
[INFO] dubbo-filter-validation ............................ SUCCESS [ 0.075 s]
[INFO] dubbo-filter-cache ................................. SUCCESS [ 0.091 s]
[INFO] dubbo-registry-default ............................. SUCCESS [ 0.076 s]
[INFO] dubbo-monitor-default .............................. SUCCESS [ 0.073 s]
[INFO] dubbo-registry-multicast ........................... SUCCESS [ 0.063 s]
[INFO] dubbo-config ....................................... SUCCESS [ 0.012 s]
[INFO] dubbo-config-api ................................... SUCCESS [ 0.139 s]
[INFO] dubbo-config-spring ................................ SUCCESS [ 0.099 s]
[INFO] dubbo-rpc-thrift ................................... SUCCESS [ 4.075 s]
[INFO] dubbo-rpc-memcached ................................ SUCCESS [ 2.741 s]
[INFO] dubbo-rpc-redis .................................... SUCCESS [ 2.312 s]
[INFO] dubbo-rpc-rest ..................................... SUCCESS [ 23.272 s]
[INFO] dubbo-registry-zookeeper ........................... SUCCESS [ 1.666 s]
[INFO] dubbo-registry-redis ............................... SUCCESS [ 1.792 s]
[INFO] dubbo .............................................. SUCCESS [ 26.157 s]
[INFO] dubbo-simple ....................................... SUCCESS [ 0.010 s]
[INFO] dubbo-registry-simple .............................. SUCCESS [ 50.771 s]
[INFO] dubbo-monitor-simple ............................... SUCCESS [ 26.226 s]
[INFO] dubbo-admin ........................................ SUCCESS [ 56.042 s]
[INFO] dubbo-demo ......................................... SUCCESS [ 0.012 s]
[INFO] dubbo-demo-api ..................................... SUCCESS [ 14.156 s]
[INFO] dubbo-demo-provider ................................ SUCCESS [ 6.241 s]
[INFO] dubbo-demo-consumer ................................ SUCCESS [ 24.484 s]
[INFO] dubbo-test ......................................... SUCCESS [ 0.012 s]
[INFO] dubbo-test-benchmark ............................... SUCCESS [ 8.547 s]
[INFO] dubbo-test-compatibility ........................... SUCCESS [ 0.062 s]
[INFO] dubbo-test-integration ............................. SUCCESS [ 0.077 s]
[INFO] dubbo-test-examples ................................ SUCCESS [ 5.373 s]
[INFO] dubbo-test-benchmark-api ........................... SUCCESS [ 1.620 s]
[INFO] dubbo-test-benchmark-server ........................ SUCCESS [ 24.342 s]
[INFO] dubbo-test-benchmark-client ........................ SUCCESS [ 24.110 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:11 min
[INFO] Finished at: 2016-02-22T20:32:27+08:00
[INFO] Final Memory: 38M/157M
[INFO] ------------------------------------------------------------------------

在各个项目的 target 目录下,会生成 对应的 jar 文件:

3. 测试 dubbox:

先转换成 eclipse 项目,执行下面的命令:

E:\Java_book\dubbo\dubbox\dubbox>mvn eclipse:eclipse

然后导入 eclipse。

然后启动 zookeeper:

1) E:\mycat\zookeeper-3.4.6\bin>zkServer.cmd

2) 运行 dubbo-demo-provider\src\test\java\com\alibaba\dubbo\demo\provider\DemoProvider.java

成功时,zookeeper会显示如下的信息:

其中的 Error 不用管,没有关系。

到这里表示 dubbox 的服务成功注册到 zookeeper 中,下面测试服务消费者:

3) 运行:dubbo-demo-consumer\src\test\java\com\alibaba\dubbo\demo\consumer\DemoConsumer.java

可以在eclipse控制台看到类似下面的信息:

[22/02/16 09:18:20:020 CST] main  INFO support.LoggingFilter:  [DUBBO] The HTTP headers are:
Accept: application/json;charset=UTF-8
Accept-Encoding: gzip, deflate
Content-Type: application/json
, dubbo version: 2.0.0, current host: 192.168.1.3
Writer interceptor invoked
Dynamic writer interceptor invoked
[22/02/16 09:18:21:021 CST] main INFO support.LoggingFilter: [DUBBO] The contents of response body is:
{"id":1,"username":"larrypage"}
, dubbo version: 2.0.0, current host: 192.168.1.3
[22/02/16 09:18:22:022 CST] main INFO support.LoggingFilter: [DUBBO] The HTTP headers are:
Content-Type: application/json;charset=UTF-8
Date: Mon, 22 Feb 2016 13:18:22 GMT
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
, dubbo version: 2.0.0, current host: 192.168.1.3
Client response filter invoked
Reader interceptor invoked
Dynamic reader interceptor invoked
[22/02/16 09:18:22:022 CST] main INFO support.LoggingFilter: [DUBBO] The contents of request body is:
{"id":9}
, dubbo version: 2.0.0, current host: 192.168.1.3
SUCCESS: registered user with id 9
Client request filter invoked
[22/02/16 09:18:22:022 CST] main INFO support.LoggingFilter: [DUBBO] The HTTP headers are:
Accept: application/json;charset=UTF-8
Accept-Encoding: gzip, deflate
, dubbo version: 2.0.0, current host: 192.168.1.3
[22/02/16 09:18:22:022 CST] main INFO support.LoggingFilter: [DUBBO] The HTTP headers are:
Content-Type: application/json;charset=UTF-8
Date: Mon, 22 Feb 2016 13:18:22 GMT
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
, dubbo version: 2.0.0, current host: 192.168.1.3
Client response filter invoked
Reader interceptor invoked
Dynamic reader interceptor invoked
[22/02/16 09:18:22:022 CST] main INFO support.LoggingFilter: [DUBBO] The contents of request body is:
{"id":1,"username":"username1"}
, dubbo version: 2.0.0, current host: 192.168.1.3
SUCCESS: got user User (id=1, name='username1')
[22/02/16 09:18:22:022 CST] main INFO container.Main: [DUBBO] Dubbo SpringContainer started!, dubbo version: 2.0.0, current host: 192.168.1.3
[2016-02-22 21:18:22] Dubbo service server started!

SUCCESS: got user User (id=1, name='username1')

调用成功。

运行:dubbo-demo-consumer\src\test\java\com\alibaba\dubbo\demo\consumer\RestClient.java

浏览访问:http://localhost:8888/services/users/100.json

显示如下:

rest 调用成功。

这里 编译和测试的 master 分支,实际应用时我们一般下载官方的release版本,比如:

https://github.com/dangdangdotcom/dubbox/releases/tag/dubbox-2.8.4

进行编译。

参考:http://www.cnblogs.com/yjmyzz/p/dubbox-demo.html

dubbox 编译 和 测试的更多相关文章

  1. 在Windows用Rebar来构建,编译,测试,发布Erlang项目

    rebar是一个遵循 Erlang/OTP 原则的 Erlang 项目构建工具,使用它可以减少构建标准 Erlang/OTP 项目架构配置的工作量,并且可以很容易的编译.测试.发布 Erlang 应用 ...

  2. dubbox编译

    dubbox编译要在命令行 切记切记 设置JAVA_HOME 设置maven路径 命令编译dubbox 设置M2_HOME环境变量 设置idea M2_HOME dubbox 服务端 http://w ...

  3. 用 rebar 来构建、编译、测试、发布 Erlang 应用程序

    转自:http://dhq.me/build-compile-eunit-release-erlang-application-with-rebar rebar 是一个遵循 Erlang/OTP 原则 ...

  4. Maven取消编译自动测试

    Maven取消编译自动测试 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins&l ...

  5. Qt 5.8 移植编译、测试

    /****************************************************************************** * Qt 5.8 移植编译.测试 * 说 ...

  6. segnet 编译与测试

    segnet 编译与测试参考:http://sunxg13.github.io/2015/09/10/caffe/http://m.blog.csdn.net/lemianli/article/det ...

  7. 在Azure DevOps Server (TFS)的流水线中编译和测试Xcode移动应用(iPhone)

    概述 Xcode是开发基于苹果macOS系统的桌面应用和移动应用的主要IDE工具.使用Azure DevOps Server (原名TFS)系统中的pipelines流水线功能,可以方便的集成Xcod ...

  8. GEOS库在windows中的编译和测试(vs2012)

    版本:vs2012, geos3.5 一.下载和编译 这类的文章比较,不再具体细说,可以参考 http://blog.csdn.net/wangqinghao/article/details/8201 ...

  9. [原]在Fedora中编译Libevent测试实例

    在我的昨天的博文<[原]我在Windows环境下的首个Libevent测试实例>中介绍了在Windows环境下如何编译一个echo server例子.今天我又试了一下在Linux环境中编译 ...

随机推荐

  1. 【Java每日一题】20161017

    20161014问题解析请点击今日问题下方的"[Java每日一题]20161017"查看 package Oct2016; import java.util.ArrayList; ...

  2. 将AJAX返回值纵向排序赋值给Table标签

    /*下面是所有拼接这个表的代码*/ 1 function HandelAjaxReturnDataForContentTable(data) { var shareHtml = "" ...

  3. tp5页面输出时,搜索后跳转下一页的处理

    tp5页面输出时,搜索功能在跳转下一页时,如果不做任何处理,会返回原有是第二页输出的数据.为了保证跳转下一页时输出的是搜索到的数据,做以下处理. (要根据自己的搜索字段进行适当修改) 页面js代码,给 ...

  4. spring 整合 struts

    struts配置 objectFactory 在struts.xml添加,用spring工厂管理action对象 <constant name="struts.objectFactor ...

  5. [AngularJS] 使用AngularCSS动态加载CSS

    [AngularJS] 使用AngularCSS动态加载CSS 前言 使用AngularAMD动态加载Controller 使用AngularAMD动态加载Service 上列两篇文章里,介绍了如何如 ...

  6. 控制器层(Controllers)

    本章译者:@freewind 业务逻辑代码通常位于模型(model)层.客户端(比如浏览器)无法直接调用其中的代码,所以模型对象提供的功能,必须作为资源以URI方式暴露给外部. 客户端使用HTTP协议 ...

  7. IClient for js开发之地图的加载

    进行web开发之前首先需要安装IServer以及iClient for JavaScript的开发包.在这两中都具备的前提下进行第一步,如何调用IServer中发布的服务 调用iServer 中发布的 ...

  8. Seen.js – 使用 SVG 或者 Canvas 渲染 3D 场景

    Seen.js 渲染3D场景为 SVG 或者 HTML5 画布.Seen.js 包含对于 SVG 和 HTML5 Canvas 元素的图形功能的最简单的抽象.所有这个库的其它组件都是不用关心将要渲染的 ...

  9. 拖放 js

    之前被小伙伴问自己能不能写一个简单的原生的 我稍微犹豫了下  这次重新学习下拖拽的过程  分享下  参考 JavaScript高级程序设计 必要的准备 自定义事件(实现事件模型)  简单来说事件模型就 ...

  10. 【追寻javascript高手之路03】javascript对象大乱斗

    前言 昨天我们学习了下javascript中函数的参数与作用域的东东,现在回过头来看,其实都是与函数相关的,所以javascript中的函数仍然是王道,我们今天大概会发二篇或者三篇博客一起来巩固我们的 ...