【问题标题】:Gradle Multiple Maven RepoGradle 多个 Maven 存储库
【发布时间】:2015-04-24 06:06:37
【问题描述】:

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

但是,根据 gradle 下面的输出,从不查看这个 repo 的工件。我怎样才能让 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")
    }
} 

【问题讨论】:

    标签: gradle build.gradle


    【解决方案1】:

    neo4j-cypher-dsl 不在 Maven 中心。它在 Neo4j 存储库中可用,您必须添加另一个存储库,如下所示:

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

    注意没有必要使用另一个maven ponting到maven central使用mavenCentral()就足够了

    编辑 1

    buildscript 中的repositories 部分仅适用于内部的依赖项。在这种情况下为 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/"
        }
    }
    

    【讨论】:

    • 嗨 Eddu 对不起,我最初在我的问题上不小心在上面发布了不正确的 build.gradle 内容。即使我在编辑中包含了 neo4j 存储库,我也遇到了同样的错误。
    • 好的,感谢更新您的问题。我的答案也被编辑了,请看一下。
    • 嗨,埃杜。谢谢那行得通。为什么在 buildscript 之外添加存储库可以解决问题?
    猜你喜欢
    • 2015-10-22
    • 1970-01-01
    • 2013-09-07
    • 2015-07-18
    • 2018-02-20
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    相关资源
    最近更新 更多