Spring源码编译及过程中的一些问题总结

本文总结了编译Spring源码的步骤,包括从GitHub下载release包,使用命令行编译并跳过测试,以及如何在Eclipse中导入项目。在编译和导入过程中遇到的问题,如编译失败和Eclipse导入后的错误,也给出了相应的解决建议,如选择合适的JDK版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

整理下最近编译Spring源码的过程以及中间的一些问题解决方法。

一、下载

 可以从GitHub直接clone,也可以下载release包

 1、clone方式

https://github.com/spring-projects/spring-framework.git

2、release包

Spring framework releases

注意:clone方式获取的是spring framework的master版本,而release包可以选择不同版本

  推荐使用release包方式获取,选择4.3.x的版本

二、编译

 在Spring-framework目录或spring-framework-4.3.x-RELEASE目录打开命令窗口,执行

gradlew build -x test

进行编译,-x 选项跳过测试

三、导入Eclipse

在Spring-framework目录或spring-framework-4.3.x-RELEASE目录打开命令窗口,执行

gradle cleanEclipse eclipse -x :eclipse

进行项目转换。

转换完成,安装File -> Import -> Existing Projects into Workspace,即可进行导入。

四、问题整理

 1、编译失败,提示信息为:

Failed to capture snapshot of input files for task ':distZip' property 'rootSpec$1$3' during up-to-date check.
> Failed to create MD5 hash for file 'D:\source\Spring-framework\build\distributions\spring-framework-4.3.14.BUILD-SNAPSHOT-schema.zip'.
出现该问题,是因为windows环境下的路径寻找问题。

解决方法:修改项目中gradle配置的Zip路径
如果是master版本,则修改 Spring-framework\gradle\docs.gradle文件
如果是4.3.x版本,则修改 Spring-framework\build.gradle文件
查找 task schemaZip(type: Zip) 模块
 it.path.endsWith("META-INF/spring.schemas")
修改为
it.path.endsWith("META-INF\\spring.schemas")
it.path.endsWith(schemas.get(key))
改为
  it.path.endsWith(schemas.get(key).replaceAll('\\/','\\\\'))

2、导入Eclipse后报错,提示GroovyDynamicElementReader这个类不存在
这是因为Eclipse缺少Groovy插件
解决方法:
 在eclipse的 Help -> Install New Software 中,添加groovy的下载连接:
 http://dist.springsource.org/milestone/GRECLIPSE/e4.4/
 选择Groovy-Eclipse(Required),开始下载,下载完后,重启eclipse,即可。

 3、导入Eclipse后报错,提示

The type java.util.concurrent.Flow$Publisher cannot be resolved. It is indirectly referenced from required .class files

解决方法:master分枝需要使用jdk9,如果是4.3.x版本的话,使用jdk8即可

   这也是前面推荐下载release包的一个原因







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值