Gradle 多个 Maven 回购

Gradle Multiple Maven Repo

我在 build.gradle 中添加了依赖项:spring-data-neo4j 它需要 neo4j-cypher-dsl-2.0.1.jar/pom,它仅位于 repo:https://repo1.maven.org/maven2/.

然而,根据下面的输出,gradle 从未查看此工件的回购协议。我怎样才能让 gradle 也搜索这个 repo。

//build.gradle
buildscript {
repositories {
    mavenCentral()
    maven {
        url "https://repo1.maven.org/maven2/"
    }
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.9.RELEASE")
}

}

gradle build:
FAILURE: Build failed with an exception.

What went wrong: Could not resolve all dependencies for configuration ':compile'.
Could not find org.neo4j:neo4j-cypher-dsl:2.0.1.   Searched in the following locations:
https://repo1.maven.org/maven2/org/neo4j/neo4j-cypher-dsl/2.0.1/neo4j-cypher-dsl-2.0.1.pom

https://repo1.maven.org/maven2/org/neo4j/neo4j-cypher-dsl/2.0.1/neo4j-cypher-dsl-2.0.1.jar Required by:

  **:feedserver:1.0.0 > org.springframework.data:spring-data-neo4j:3.2.2.RELEASE**

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

编辑:------------------------------------ 对不起,我不小心发布了上面不正确的 build.gradle 内容,其中重复了 maven 中心位置。这是我实际的 build.gradle 文件...当我使用这些设置构建时,我仍然收到上述错误:

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "http://m2.neo4j.org/content/repositories/releases/" 
        }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.9.RELEASE")
    }
} 

neo4j-cypher-dsl 不在 Maven 中心。它在 Neo4j 存储库中可用,您必须添加另一个像这样的存储库:

repositories {
    maven {
        url "http://m2.neo4j.org/content/repositories/releases/" 
    }
}

注意 没有必要使用另一个 Maven 使用 mavenCentral() 连接到 Maven Central 就足够了

编辑 1

repositories buildscript 部分仅适用于内部依赖项。在这种情况下 spring-boot-gradle-plugin

buildscript {
    ext {
        springBootVersion = '1.1.9.RELEASE'
    }
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

在你的情况下,你想为你的项目添加另一个依赖项。因此,您需要从 buildscript

中添加另一个 repositories 部分
repositories {
    mavenLocal()
    mavenCentral()
    maven {
        url "http://m2.neo4j.org/content/repositories/releases/"
    }
}