dubbo原始碼編譯(頂)
cd dubbo
mvn clean install -Dmaven.test.skip
報錯:
Non-resolvable parent POM: Could not transfer artifact com.alibaba:opensesame:pom:2.0 from/to opensesame.releases (http://code.alibabatech.com/mvn/releases)
README上已經說明了需要本地安裝“由於開源站點因為安全問題被下掉,如果編譯時出現找不到opensesame依賴情況的,請先手動下載https://github.com/alibaba/opensesame
下載opensesame,之後進入opensesame目錄,執行:mvn install 等待success吧
再次執行:
mvn clean install -Dmaven.test.skip
又是一堆的錯誤啊:
[ERROR] Failed to execute goal on project dubbo-common: Could not resolve dependencies for project com.alibaba:dubbo-common:jar:2.5.4-SNAPSHOT: Failed to collect dependencies for [org.slf4j:slf4j-api:jar:1.6 .2 (provided), commons-logging:commons-logging-api:jar:1.1 (provided), log4j:log4j:jar:1.2.16 (compile), org.javassist:javassist:jar:3.15.0-GA (compile), com.alibaba:hessian-lite:jar:3.2.1-fixed-2 (compile), com.alibaba:fastjson:jar:1.1.8 (provided), org.jvnet.sorcerer:sorcerer-javac:jar:0.8 (provided), cglib:cglib-nodep:jar:2.2 (test), junit:junit:jar:4.10 (test), org.easymock:easymock:jar:3.0 (test), org.easymock:easymockclassextension:jar:3.0 (test), com.googlecode.jmockit:jmockit:jar:0.999.8 (test)]: Failed to read artifact descriptor for com.alibaba:hessian-lite:jar:3.2.1-fixed-2: Could not transfer artifact com.alibaba:hessian-lite:pom:3.2.1-fixed-2 from/to opensesame.releases (http://code.alibabatech.com/mvn/releases): Connection to http://code.alibabatech.com refused: Connection refused -> [Help 1]
<mirror>
<id>kafeitu</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://maven.kafeitu.me/nexus/content/repositories/public</url>
</mirror>
<mirror>
<id>ibiblio.org</id>
<name>ibiblio Mirror of http://repo1.maven.org/maven2/</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
<mirrorOf>*</mirrorOf>
</mirror>
<mirror>
<id>lvu.cn</id>
<name>lvu.cn</name>
<url>http://lvu.cn/nexus/content/groups/public</url>
<mirrorOf>*</mirrorOf>
</mirror>
將上面的配置加入maven配置檔案setting.xml中
再次執行:
mvn clean install -Dmaven.test.skip
依然報錯:
[ERROR] Failed to execute goal on project dubbo-common: Could not resolve dependencies for project com.alibaba:dubbo-common:jar:2.5.4-SNAPSHOT: Failed to collect dependencies for [org.slf4j:slf4j-api:jar:1.6.2 (provided), commons-logging:commons-logging-api:jar:1.1 (provided), log4j:log4j:jar:1.2.16 (compile), org.javassist:javassist:jar:3.15.0-GA (compile), com.alibaba:hessian-lite:jar:3.2.1-fixed-2 (compile), com.alibaba:fastjson:jar:1.1.8 (provided), org.jvnet.sorcerer:sorcerer-javac:jar:0.8 (provided), cglib:cglib-nodep:jar:2.2 (test), junit:junit:jar:4.10 (test), org.easymock:easymock:jar:3.0 (test), org.easymock:easymockclassextension:jar:3.0 (test), com.googlecode.jmockit:jmockit:jar:0.999.8 (test)]: Failed to read artifact descriptor for com.alibaba:hessian-lite:jar:3.2.1-fixed-2: Could not find artifact com.alibaba:opensesame:pom:1.0 in ibiblio.org (http://mirrors.ibiblio.org/pub/mirrors/maven2) -> [Help 1]
在這個錯誤檔案中發現了Could not find artifact com.alibaba:opensesame:pom:1.0,不是2.0麼,怎麼1.0也要。既然需要,那咱就給唄。
還記得上面自己下載的opensesame原始碼不,修改下面的pom.xml,將 <version>2.0</version>中2.0修改為1.0
執行 mvn install 等待success吧
再次執行:
mvn clean install -Dmaven.test.skip
依然出錯
[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]
再次執行:
mvn clean install -Dmaven.test.skip
我靠還是有錯,這次居然是
java.lang.OutOfMemoryError: PermGen space
就是不讓人省心啊,繼續解決,採用粗暴直接的方式,直接修改maven安裝目錄下bin/mvn,在上面加上這個
MAVEN_OPTS="$MAVEN_OPTS -Xms256m -Xmx1024m -XX:MaxPermSize=128m -XX:ReservedCodeCacheSize=64m"
具體大小,可根據自己的情況調整
再次執行:
mvn clean install -Dmaven.test.skip
還是出錯了呀呀呀...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project dubbo-rpc-redis: Compilation failure: Compilation failure:
[ERROR] /home/pengkw/opensource/dubbo-dubbo-2.4.10/dubbo-rpc/dubbo-rpc-redis/src/main/java/com/alibaba/dubbo/rpc/protocol/redis/RedisProtocol.java:[25,35] package org.apache.commons.pool.impl does not exist
[ERROR] /home/pengkw/opensource/dubbo-dubbo-2.4.10/dubbo-rpc/dubbo-rpc-redis/src/main/java/com/alibaba/dubbo/rpc/protocol/redis/RedisProtocol.java:[71,29] package GenericObjectPool does not exist
[ERROR] /home/pengkw/opensource/dubbo-dubbo-2.4.10/dubbo-rpc/dubbo-rpc-redis/src/main/java/com/alibaba/dubbo/rpc/protocol/redis/RedisProtocol.java:[71,67] package GenericObjectPool does not exist
[ERROR] /home/pengkw/opensource/dubbo-dubbo-2.4.10/dubbo-rpc/dubbo-rpc-redis/src/main/java/com/alibaba/dubbo/rpc/protocol/redis/RedisProtocol.java:[89,40] cannot access org.apache.commons.pool.PoolableObjectFactory
[ERROR] class file for org.apache.commons.pool.PoolableObjectFactory not found
[ERROR] final JedisPool jedisPool = new JedisPool(config, url.getHost(), url.getPort(DEFAULT_PORT),
[ERROR] -> [Help 1]
直接上解決方法:分別修改dubbo-rpc/dubbo-rpc-redis/pom.xml和dubbo-registry/dubbo-registry-redis/pom.xml檔案,在dependencies下加入jar包依賴
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.6</version>
</dependency>
再次執行:
mvn clean install -Dmaven.test.skip
經過一段漫長的過程,終於看到了build success
好吧,至此整個原始碼的編譯過程已經完成,本身沒有什麼難度,只是因為缺少相關的jar和環境配置,導致一系列的問題。
轉載於:http://www.jianshu.com/p/0dde591f21d0