我正在尝试运行一个项目。它无法找到依赖。所以我在pom.xml中添加了存储库
但它无法查找相同内容。
来自pom.xml
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<id>spring</id>
<name>Spring Framework Maven Release Repository</name>
<url>http://oss.sonatype.org/content/groups/public</url>
<layout>default</layout>
</repository>
</repositories>
81749 [警告]无法为其创建Maven项目 com.gemstone.gemfire:gemfire:pom:8.1.0来自存储库。 org.apache.maven.project.ProjectBuildingException:解析错误 项目工件:找不到 com.gemstone.gemfire:gemfire:pom:8.1.0 in https://repo.maven.apache.org/maven2被缓存在当地 存储库,在更新之前不会重新尝试解析 中心间隔已过,或者强制更新项目 com.gemstone.gemfire:的GemFire:POM:8.1.0
当我申请-X时,我看到以下
103850 [DEBUG] === PROJECT BUILD PLAN ================================================
103850 [DEBUG] Project: xxxxx:xxxxxx:0.0.1-SNAPSHOT
103850 [DEBUG] Dependencies (collect): [compile+runtime]
103850 [DEBUG] Dependencies (resolve): [compile, compile+runtime, runtime, test]
103850 [DEBUG] Repositories (dependencies): [central (https://repo.maven.apache.org/maven2, default, releases)]
103850 [DEBUG] Repositories (plugins) : [central (https://repo.maven.apache.org/maven2, default, releases)]
我在这里缺少什么?我有父pom.xml和存储库提及
父母不包括在孩子
中答案 0 :(得分:1)
鉴于此pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.gemstone.gemfire</groupId>
<artifactId>gemfire</artifactId>
<version>8.1.0</version>
</dependency>
</dependencies>
</project>
当我试图跑步时:
$mvn clean compile
结果是:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/com/gemstone/gemfire/gemfire/8.1.0/gemfire-8.1.0.pom
[WARNING] The POM for com.gemstone.gemfire:gemfire:jar:8.1.0 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/com/gemstone/gemfire/gemfire/8.1.0/gemfire-8.1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.642 s
[INFO] Finished at: 2017-04-02T13:31:34+01:00
[INFO] Final Memory: 11M/131M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project test: Could not resolve dependencies for project test:test:jar:0.1-SNAPSHOT: Could not find artifact com.gemstone.gemfire:gemfire:jar:8.1.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
所以我研究了mvnrepository.com中的依赖关系和存储库,我发现包含这种依赖关系的存储库是Spring Plugins和Spring Libs:
然后我刚刚在我的pom中添加了Spring Plugins存储库,它确实有效!
最终的POM是:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.gemstone.gemfire</groupId>
<artifactId>gemfire</artifactId>
<version>8.1.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring</id>
<url>http://repo.spring.io/plugins-release</url>
</repository>
</repositories>
</project>