1

我正在尝试将我的应用程序从使用嵌入式 neo4j 数据库“升级”为使用基于服务器的设置。

我使用 spring 作为设置简单存储库的框架,它就像一个魅力。

现在我正在尝试包含 org.springframework.data:spring-data-neo4j 的依赖项,以便能够连接到 neo4j 服务器。但它对于 gradle 和 maven 以及不同版本的 spring data neo4j rest 都失败了。并且在获取 pom 时有一个新的例外 401 Unauthorized:

* What went wrong:
  Could not resolve all dependencies for configuration ':compile'.
> Could not resolve org.neo4j:neo4j-rest-graphdb:1.9.
Required by:
  :recipeCrawlers:unspecified > org.springframework.data:spring-data-neo4j-rest:2.4.0.BUILD-SNAPSHOT
> Could not HEAD 'http://repo.spring.io/libs-snapshot/org/neo4j/neo4j-rest-graphdb/1.9/neo4j-rest-graphdb-1.9.pom'. Received status code 401 from server: Unauthorized

任何人都知道我做错了什么

我的 build.gradle 的一部分是:

buildscript {
repositories {
    maven { url 'http://m2.neo4j.org/content' }
    maven { url "http://repo.spring.io/libs-snapshot" }
    mavenLocal()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.M5")
}
}

apply plugin: 'java'  
apply plugin: 'eclipse'
apply plugin: 'spring-boot'

jar {
baseName = 'crawlers'
version =  '0.1.0'
} 

repositories {
 mavenCentral()
 maven { url "http://repo.spring.io/libs-snapshot" }
}

dependencies {
 compile("org.springframework.boot:spring-boot-starter:0.5.0.M5")
 compile("org.springframework.data:spring-data-mongodb:1.3.2.RELEASE")
 compile("com.google.guava:guava-collections:r03")
 compile("org.apache.commons:commons-lang3:3.0")
 compile 'org.springframework.data:spring-data-neo4j:2.4.0.BUILD-SNAPSHOT'
 compile 'org.springframework.data:spring-data-neo4j-rest:2.4.0.BUILD-SNAPSHOT'
 //    compile 'org.neo4j:neo4j-rest-graphdb:1.9'

 compile 'javax.validation:validation-api:1.1.0.Final'
 compile 'org.hibernate:hibernate-validator:5.0.1.Final'

 // compile 'org.neo4j:neo4j-cypher:'

 testCompile("junit:junit:4.11")
}

task wrapper(type: Wrapper) {
 gradleVersion = '1.8'
}

使用具有相同依赖项的 Maven,我收到此错误:

Could not resolve dependencies for project com.emaat-sample:jar:0.0.1-SNAPSHOT: Failed to   collect dependencies for [org.springframework.boot:spring-boot-starter:jar:0.5.0.M5 (compile), org.springframework.data:spring-data-neo4j:jar:2.4.0.BUILD-SNAPSHOT (compile), org.springframework.data:spring-data-neo4j-rest:jar:2.4.0.BUILD-SNAPSHOT (compile), junit:junit:jar:4.11 (test), org.mockito:mockito-core:jar:1.9.5 (test), org.hamcrest:hamcrest-library:jar:1.3 (test)]: Failed to read artifact descriptor for org.neo4j:neo4j-rest-graphdb:jar:1.9: Could not transfer artifact org.neo4j:neo4j-rest-graphdb:pom:1.9 from/to spring-snapshots (http://repo.spring.io/libs-snapshot): Not authorized, ReasonPhrase:Unauthorized. -> [Help 1]

我的 pom 文件:http://maven.apache.org/xsd/maven-4.0.0.xsd">4.0.0 com.emaat 示例 0.0.1-SNAPSHOT 示例

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>0.5.0.M5</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-neo4j</artifactId>
        <version>2.4.0.BUILD-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-neo4j-rest</artifactId>
        <version>2.4.0.BUILD-SNAPSHOT</version>
    </dependency>
</dependencies>

<!-- Package as an executable JAR -->
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/libs-snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/libs-snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>
</project>
4

1 回答 1

3

我在尝试解决“org.restlet.jee:org.restlet.ext.servlet:2.1.1”依赖时遇到了同样的问题,因为它对我来说是一个传递依赖。原来“org.restlet.jee:org.restlet.ext.servlet:2.1.1”在 Maven Central 中不存在,所以 gradle 将尝试 Spring IO Repository。Spring IO Repository 有一些限制,并且会为某些依赖项抛出安全异常。

org.neo4j:neo4j-rest-graphdb:1.9 似乎也是如此。快速搜索显示这在 Maven Central 中不存在,因此您必须添加一个新存储库(我在 Spring IO 存储库之前添加了我的存储库)。通过添加存储库,我能够继续使用 Spring Boot。

我确实重新创建了您的问题,并通过将存储库部分更改为:

repositories {
    mavenCentral()
    maven { url "http://m2.neo4j.org/content/repositories/releases/" }
    maven { url "http://repo.spring.io/libs-snapshot" }
}
于 2014-01-10T03:59:25.693 回答