Gradle依赖管理插件

时间:2018-03-19 15:23:20

标签: gradle

我正在尝试运行以下最小gradle构建文件,包括依赖项管理插件:

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
}

plugins {
    id "java"
    id "io.spring.dependency-management" version "1.0.4.RELEASE"
}

但是然后运行gradle失败了:

* What went wrong:
Plugin [id: 'io.spring.dependency-management', version: '1.0.4.RELEASE'] 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 'io.spring.dependency-management:io.spring.dependency-management.gradle.plugin:1.0.4.RELEASE')
  Searched in the following repositories:
    Gradle Central Plugin Repository

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.5.1/userguide/command_line_interface.html#sec:command_line_warnings

gradle文件中是否缺少依赖项?

1 个答案:

答案 0 :(得分:1)

无法找到该插件,因为您在构建脚本中定义了存储库并尝试在其外部使用插件。删除buildscript或为您的构建文件添加存储库。
(构建脚本中定义的依赖关系和存储库可在该构建脚本范围内访问)

示例:

plugins {
    id "java"
    id "io.spring.dependency-management" version "1.0.4.RELEASE"
}

repositories {
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }