本文以dubbo2.4.11源码编译和打包例
dubbo官网:http://dubbo.io/
源码:https://github.com/alibaba/dubbo
用户指南:http://dubbo.io/User+Guide-zh.htm
开发指南:
按官方说明2.4.X是GA稳定版本,去https://github.com/alibaba/dubbo/releases下载最新的2.4.11
解压到D:\project\dubbo\dubbo-dubbo-2.4.11
在编译dubbo前,先执行下面操作
1、opensesame依赖问题,可能会报Non-resolvable parent POM: Could not transfer artifact com.alibaba:opensesame:pom:2.0 from/to opensesame.releases (http://code.alibabatech.com/mvn/releases)
的错误。
打开https://github.com/alibaba/opensesame,下载opensesame(主要是pom.xml文件),解压在D:\project\dubbo\opensesame-master目录
在D:\project\dubbo\opensesame-master目录下,cmd命令行执行
mvn clean install -Dmaven.test.skip
编译完成后,修改D:\project\dubbo\opensesame-master\pom.xml,把版本2.0修改为1.0,
com.alibaba opensesame 1.0 pom
相同目录再编译一次opensesame
mvn clean install -Dmaven.test.skip
2、fastjson依赖包,可能报[ERROR] Failed to execute goal on project dubbo-common: Could not resolve dependencies for project com.alibaba:dubbo-common:jar:2.5.4-SNAPSHOT: Could not find artifact com.alibaba:fastjson:jar:1.1.8 in ibiblio.org (http://mirrors.ibiblio.org/pub/mirrors/maven2) -> [Help 1]错误
修改D:\project\dubbo\dubbo-dubbo-2.4.11\pom.xml,找到 <fastjson_version>1.1.8</fastjson_version>,将1.1.8修改为1.1.39,参考https://github.com/alibaba/dubbo/issues/22
3、注释D:\project\dubbo\dubbo-dubbo-2.4.11\pom.xml下边的内容
opensesame.releases http://code.alibabatech.com/mvn/releases true false
4、hessian-lite依赖包,Unable to find resource 'com.alibaba:hessian-lite:jar:3.2.1-fixed-2' in repository central.repo (http://repo1.maven.org/maven2)
从github的dubbo主库中下载hessian-lite,当前最新的dubbo源码中已带有hessian-lite源码,可以直接取出来加到dubbo 2.4.11中编译(https://github.com/alibaba/dubbo,https://github.com/alibaba/dubbo/tree/master/hessian-lite)
把hessian-lite拷贝到D:\project\dubbo\dubbo-dubbo-2.4.11,
修改D:\project\dubbo\dubbo-dubbo-2.4.11\pom.xml,增加<module>hessian-lite</module>编译
hessian-lite dubbo-common dubbo-container dubbo-remoting dubbo-rpc dubbo-filter dubbo-cluster dubbo-registry dubbo-monitor dubbo-config dubbo
修改D:\project\dubbo\dubbo-2.4.11\hessian-lite\pom.xml
com.alibaba dubbo-parent 2.4.11
5、增加编译dubbo管理控制台,这一步不是必须的,主要是官方的dubbo管理控制台下载不了,直接自己编译一个,默认下不编译打包dubbo-admin,需要自己增加。
修改D:\project\dubbo\dubbo-2.4.11\dubbo-admin\pom.xml文件,把版本号改为2.4.11
com.alibaba dubbo-parent 2.4.11
修改D:\project\dubbo\dubbo-dubbo-2.4.11\pom.xml,增加<module>dubbo-admin</module>编译
hessian-lite dubbo-common dubbo-container dubbo-remoting dubbo-rpc dubbo-filter dubbo-cluster dubbo-registry dubbo-monitor dubbo-config dubbo dubbo-admin
6、正式编译dubbo
1)cmd命令行,在D:\project\dubbo\dubbo-dubbo-2.4.11目录下执行命令:
先设置maven内存,否则编译时会报内存不足错误
set MAVEN_OPTS=-Xmx1024m -XX:MaxPermSize=512mmvn clean install -Dmaven.test.skip
7、添加eclipse支持
在D:\project\dubbo\dubbo-dubbo-2.4.11目录下执行命令:
mvn eclipse:eclipse
可以直接在eclipse运行下边几个程序
dubbo-demo-provider/src/test/java/com.alibaba.dubbo.demo.provider.DemoProvider
dubbo-demo-consumer/src/test/java/com.alibaba.dubbo.demo.consumer.DemoConsumer
dubbo-monitor-simple/src/test/java/com.alibaba.dubbo.monitor.simple.SimpleMonitor
dubbo-registry-simple/src/test/java/com.alibaba.dubbo.registry.simple.SimpleRegistry
8、dubbo-admin管理控制台安装
第6步执行完成后,D:\project\dubbo\dubbo-2.4.11\dubbo-admin\target目录会生成dubbo-admin-2.4.11.war,
war包解压到webapps/ROOT目录下,修改WEB-INF\dubbo.properties,
dubbo.registry.address=zookeeper://127.0.0.1:2181dubbo.admin.root.password=rootdubbo.admin.guest.password=guest
dubbo.properties配置zookeeper的注册中心地址(zookeeper的安装配置忽略)
注意:确定zookeeper启动后再去启动tomcat。