好奇怪,在自己电脑上,下载好了源码,然后点击源码包中的import-into-eclipse.bat然后等待,可以按任意键就按任意键,然后就build success了,我擦,好奇怪,任何设置操作都不需要,就是得注意一点,就是jdk需要7,jdk8的话会报错... 在公司电脑上都一直都有问题,一天了都没弄好....麻麻蛋啊...无语!!!build success后,eclipse导入时 existing projects into Workspace 记得要勾选上 search for nested projects,这样才会把子项目也导入eclipse,这样才正常...
如果导入eclipse后还是有错误信息,则再执行一次import-into-eclipse.bat,且在导入到eclipse之后在cmd界面点击任意键退出cmd界面
《Spring 源码深度解析》书本来进行学习。所以采用的环境也是与其保持一直。
公司电脑出现的问题为:
A problem occurred configuring root project 'spring'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve org.springframework.build.gradle:propdeps-plugin:0.0.7.
Required by:
:spring:3.2.19.BUILD-SNAPSHOT
> Could not GET 'https://repo.spring.io/plugins-release/org/springframework/build/gradle/propdeps-plugin/0.0.7/propdeps-plugin-0.0.7.pom'.
> peer not authenticated
> Could not resolve org.asciidoctor:asciidoctor-gradle-plugin:1.5.2.
Required by:
:spring:3.2.19.BUILD-SNAPSHOT
> Could not GET 'https://repo.spring.io/plugins-release/org/asciidoctor/asciidoctor-gradle-plugin/1.5.2/asciidoctor-gradle-plugin-1.5.2.pom'.
> peer not authenticated
> Could not resolve io.spring.gradle:docbook-reference-plugin:0.3.1.
Required by:
:spring:3.2.19.BUILD-SNAPSHOT
> Could not GET 'https://repo.spring.io/plugins-release/io/spring/gradle/docbook-reference-plugin/0.3.1/docbook-reference-plugin-0.3.1.pom'.
> peer not authenticated
> Could not resolve ws.antonov.gradle.plugins:gradle-plugin-protobuf:0.9.1.
Required by:
:spring:3.2.19.BUILD-SNAPSHOT
> Could not GET 'https://repo.spring.io/plugins-release/ws/antonov/gradle/plugins/gradle-plugin-protobuf/0.9.1/gradle-plugin-protobuf-0.9.1.pom'.
> peer not authenticated
解决方案:
修改maven仓库
repositories { maven { url "http://repo.springsource.org/plugins-release" } }
********************************以下为网上查找总结的********************************
一.下载Spring源码
spring源码托管在GitHub上。犹豫墙的存在,所以很多人安装GitHub不太现实。因此不要轻信网上的先安装GitHub。下面是Spring各个版本源码下载地址
https://github.com/spring-projects/spring-framework/releases
打开连接,我们选择3.2.0版本的Spring下载。下载完毕保存到本地硬盘。
二.编译spring源码(不额外自己安装gradle)
编译源码过程中,你只需要使用spring自带的gradlew.bat就行,即gradlew -build。注意多了个w.本来下载spring的jar包就很慢,再下载个gradle(40M左右),就更慢]。
Spring采用的是Gradle进行项目管理,官网地址:
http://gradle.org/overview
通过命令行进入刚在下载的目录(双击gradlew.bat貌似也可以),运行:
./gradlew build
开始下载gradle程序和依赖的jar文件等。这个过程比较耗时。等待……
半个小时之后,居然……failed!
查看原因原来是测试代码failed,于是重新执行命令
./gradlew build –x test 忽略测试代码,终于编译成功
执行
./gradlew install 将jar包安装到gradle库
接下来是将源码导入到IDE中。
由于我是windows用户,所以参考import-into-idea.md的说明
这里,由于我使用的是eclipse,所以执行:
./gradlew cleanIdea eclipse 生成Eclipse导入需要的文件
剩下的就是导入文件了:
三.以下是编译过程中的报错。
1、spring 自带的gradlew.bat编译会出现: Execution failed for task':referencePdf'
编译过程中出现如下错误
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':referencePdf'.
> Java heap space
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2 mins 0.683 secs
看下错误日志,发现需要调整 gradlew.bat文件中的 MaxHeapSize 的大小
set GRADLE_OPTS=-XX:MaxPermSize=512m -Xmx512m -XX:MaxHeapSize=512m %GRADLE_OPTS%
2、window运行gradlew.bat build -x test --stacktrace出现找不到文件framework-3.2.19.BUILD-SNAPSHOT-schema.zip异常
编辑build.gradle文件
替换成
task schemaZip(type: Zip) {
group = "Distribution"
baseName = "spring-framework"
classifier = "schema"
description = "Builds -${classifier} archive containing all " +
"XSDs for deployment at http://springframework.org/schema."
duplicatesStrategy 'exclude'
moduleProjects.each { subproject ->
def Properties schemas = new Properties();
subproject.sourceSets.main.resources.find {
it.path.endsWith("META-INF\\spring.schemas")
}?.withInputStream { schemas.load(it) }
for (def key : schemas.keySet()) {
def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, '$1')
assert shortName != key
File xsdFile = subproject.sourceSets.main.resources.find {
it.path.endsWith(schemas.get(key).replaceAll('\\/','\\\\'))
}
assert xsdFile != null
into (shortName) {
from xsdFile.path
}
}
}
}
后重新执行命令
3、spring-oxm缺少lib的问题见附录中的参考教程第三点即可
四.附录:
参考教程:
1、SpringFramework源码下载和编译教程:http://mushiqianmeng.blog.51cto.com/3970029/787211/
2、spring 源码如何导入到eclipse:http://blog.csdn.net/zeuskingzb/article/details/41425421
3、源码编译spring:https://my.oschina.net/zhongwenhao/blog/701071