Spring 源码编译遇到的坑
-
系统 : Mac
-
idea版本 :2019.3
-
gradle :两个版本,4.10.3 和 5.5.1
-
Spring 版本:v5.1.17.RELEASE
按照官方给的说明:
- 下载源码,先不要打开,进入源码目录,执行 ./gradlew :spring-oxm:compileTestJava,这个时候它会自动下载gradle 4.10.3 (好吧,我得承认,前前后后,gradle的版本我下载了n个, Spring 的源码版本我也下载了n个, 只有这个编译通过了)
- 导入项目 Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)
- 当你遇到提示时,可以移除 Spring-aspects 这个模块(我没遇到)
- 干吧
下载依赖这个情况吧,我是全局替换成了阿里云的镜像,所以就没有再改build.gradle, 在你的用户目录下新建一个init.gradle,填入以下内容
allprojects{ repositories { def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public/' def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter/' def ALIYUN_GOOGLE_URL = 'https://maven.aliyun.com/repository/google/' def ALIYUN_GRADLE_PLUGIN_URL = 'https://maven.aliyun.com/repository/gradle-plugin/' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL." remove repo } if (url.startsWith('https://dl.google.com/dl/android/maven2/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GOOGLE_URL." remove repo } if (url.startsWith('https://plugins.gradle.org/m2/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GRADLE_PLUGIN_URL." remove repo } } } maven { url ALIYUN_REPOSITORY_URL } maven { url ALIYUN_JCENTER_URL } maven { url ALIYUN_GOOGLE_URL } maven { url ALIYUN_GRADLE_PLUGIN_URL } }}
然后开始编译,我是遇到了各种各样的错,错误列表如下
-
Received close_notify during handshake,换了Spring版本解决的,搜索无果
-
ReadTimeOut 应该是网络慢,可以尝试换阿里云
-
fatal: not a git repository (or any of the parent directories): .git 搜索无果,建议换 Spring 版本
-
exception during working with external system: java.lang.AssertionError
at org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension.createModule(BaseGradleProjectResolverExtension.java:154)
at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) Gradle版本问题,修改 源码目录下的 gradle/wrapper/gradle-wrapper.propertiesdistributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
#distributionUrl=https://services.gradle.org/distributions/gradle-4.10.3-bin.zip
distributionUrl=https://services.gradle.org/distributions/gradle-5.5.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
idea的相关配置如下:
如果,运气好的话,你应该就可以编译通过了,接下来建立测试模块
Hello world
如果,你建立了测试模块后,写代码没有提示,加下依赖,在你测试模块的 build.gradle里
dependencies {
compile(project(":spring-context"))
compile(project(":spring-beans"))
testCompile group: 'junit', name: 'junit', version: '4.12'
}
本文地址:https://blog.csdn.net/qq_28163609/article/details/108167495
上一篇: Android studio开发入门级git命令(一)
下一篇: aosp编译出错