2017-03-31 57 views
0

我正在嘗試運行項目。它無法找到依賴關係。所以我在pom.xml中添加了倉庫即使我指定了回購,maven依賴查找失敗

但是它無法查找相同。

從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在 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

您已經定義並沒有真正意義上面的資料庫,導致所有這些文物已經在Maven的中央。您遇到的問題是,給定的依賴關係'com:gemstone.gemfire'不在Maven中心......只在這裏:https://network.pivotal.io/products/pivotal-gemfire – khmarbaise

+0

它不僅僅是這個...例如spring-cloud-netflix-zuul-server在maven中心也不存在 –

+0

由org.eclipse.aether.transfer.ArtifactNotFoundException導致:無法在https:中找到javax-inject:javax-inject:pom:1。 //repo.maven.apache.org/maven2緩存在本地存儲庫中,直到中央更新間隔已過或更新被強制爲止,分辨率纔會被重新嘗試。 以及更多 –

回答

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插件和Spring利布斯:

enter image description here

然後,我剛添加的春天插件庫在我的POM和有效!

最終的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> 
+0

謝謝你一樣...但它也沒有工作。這一次,神器出現在回購中。我在這裏添加了更多細節。 http://stackoverflow.com/questions/43281165/unable-to-run-maven-build-on-gitlab-dependacy-missing-but-present-in-maven-centr –

+0

謝謝。我也是這樣工作的。但是:我想讓它工作?這個插件是什麼,我想要它?我只知道這個錯誤只發生在生成網站報告時,而我在運行我的應用程序時並不需要這個插件。它只出現在我的網站報告的依賴管理頁面中,甚至沒有許可證。 – Alexander