昨天在利用Gradle构建Spring5源码的过程中,出现了很多问题:
- Gradle版本为最新版
6.8.3
- Idea版本更新前为
2018
- Spring版本截至发文时为最新版
5.5.x
一、可能是缓存问题
org.gradle.internal.exceptions.LocationAwareException: Settings file 'G:\IdeaProject\spring-framework\settings.gradle' line: 9
Plugin [id: 'com.gradle.enterprise', version: '3.5.1'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.gradle.enterprise:com.gradle.enterprise.gradle.plugin:3.5.1')
Searched in the following repositories:
Gradle Central Plugin Repository
maven(https://repo.spring.io/plugins-release)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolveToFoundResult(DefaultPluginRequestApplicator.java:214)
at
// 省略.......
org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.lambda$resolvePluginRequestorg.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.gradle.enterprise', version: '3.5.1'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.gradle.enterprise:com.gradle.enterprise.gradle.plugin:3.5.1')
Searched in the following repositories:
Gradle Central Plugin Repository
maven(https://repo.spring.io/plugins-release)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolveToFoundResult(DefaultPluginRequestApplicator.java:213)
... 141 more
解决方案:
- 删除
<USER_HOME>/.gradle
下的文件,然后重新构建。
二、Gradle与Idea版本不匹配
Cause: org.jetbrains.plugins.gradle.tooling.util.ModuleComponentIdentifierImpl.getModuleIdentifier()
发生这个错误的时候,我的版本是这样的:
- Idea
2018
- Gradle
6.8.3
根据网上大佬们的解决方案得,需要升级Idea,或者降级Gradle。
随后我将Idea升级为2021.3,再次Build,成功。