今天将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