我正在尝试“升级”我的应用程序,使用嵌入式neo4j数据库来使用基于服务器的设置。
我使用spring作为设置简易存储库的框架,它就像一个魅力。
现在我正在尝试为org.springframework.data:spring-data-neo4j添加一个依赖项,这样我就可以连接到neo4j服务器了。但它对于gradle和maven都是失败的,并且对于不同版本的spring数据neo4j休息。在获得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>
答案 0 :(得分:3)
我在尝试解决“org.restlet.jee:org.restlet.ext.servlet:2.1.1”依赖关系时遇到了同样的问题,因为它对我来说是一个传递依赖。事实证明,Maven Central中不存在“org.restlet.jee:org.restlet.ext.servlet:2.1.1”,因此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" }
}