今天將spring源碼導入到idea遇到的問題,如下對應的解決辦法
1. 沒法從github上下載源碼->https://zhuanlan.zhihu.com/p/102409790
2. 構建失敗 -> https://www.cnblogs.com/yufeng218/p/9235746.htmlhtml
按上面的辦法操做後,構建時仍是失敗,不斷嘗試的過程當中,最終成功導入到了idea.
主要問題在於gradle的版本不對,個人gradle版本是5.4,最後換成5.6.4的版本,就成功了。git
a. 在C:\Users\zerli.gradle目錄下建立文件init.gradle,內容以下github
allprojects{ repositories { def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public' def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('http://repo1.maven.org/maven2')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/') || url.startsWith('http://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL." remove repo } } } maven { url ALIYUN_REPOSITORY_URL url ALIYUN_JCENTER_URL } } buildscript{ repositories { def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public' def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('http://repo1.maven.org/maven2')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/') || url.startsWith('http://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL." remove repo } } } maven { url ALIYUN_REPOSITORY_URL url ALIYUN_JCENTER_URL } } } }
b. 在spring-framework目錄下的build.gradle中,第一行加入web
buildscript { repositories { maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' } } dependencies { classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.21.RELEASE' } }
在plugins後面加入spring
allprojects { repositories { maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' } } }
註釋掉maven
id 'io.spring.gradle-enterprise-conventions' version '0.0.2'
修改原來的文件的repositories內容爲ide
repositories { mavenCentral() maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' } maven { url "https://repo.spring.io/libs-spring-framework-build" } }
c. 修改spring-framework文件夾下的settings.gradle文件,將第4行改成svg
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
d. 在spring-oxm目錄下執行spring-boot
$ gradle :spring-oxm:compileTestJava
來看下成功導入的效果圖
gradle