2011-06-30 154 views
4

摘要:
運行 「MVN戰爭:戰爭」 失敗,錯誤包括:
「下面的文物無法解析:org.openid4java:openid4java:罐子:0.9.6" 。Maven的 「無法解析的依賴關係」 爲openid4java

我會記下它的事實,即我是Maven noob,但我看到其他人已發佈到openid4java網站,聲明來自Maven中心的jars are missing for openid4java。

詳情:
我試圖站起來通過運行中包含的openid4java(0.9.6.662)的最新版本的簡單的OpenID的示例應用程序與openid4java加快。

根據自述「此演示要求 apache Maven2構建」。自述文件還指出:「軍事戰爭:戰爭任務應該創建一個可以通過複製戰爭文件來部署的戰爭文件」。

到現在爲止,我一直在用Ant和Mavent Ant Tasks來解決問題,但我想我今天會咬緊牙關並安裝Maven 3.0.3。我遵循安裝說明,現在可以成功運行「mvn --version」

當我運行「mvn war:war」時,確實有很多文件被下載到我的本地存儲庫中,但最終生成失敗,出現以下摘錄消息:

[ERROR] Failed to execute goal on project simple-openid: Could not resolve dependencies for project org.openid4java:simple-openid:war:0.9.6: The following artifacts could not be resolved: org.openid4java:openid4java:jar:0.9.6, org.openid4java:openid4java-consumer:jar:0.9.6, org.openid4java:openid4java-server:jar:0.9.6, org.openid4java:openid4java-server-JdbcServerAssociationStore:jar:0.9.6, org.openid4java:openid4java-consumer-SampleConsumer:jar:0.9.6, org.openid4java:openid4java-server-SampleServer:jar:0.9.6: Failure to find org.openid4java:openid4java:jar:0.9.6 in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project simple-openid: Could not resolve dependencies for project org.openid4java:simple-openid:war:0.9.6: The following artifacts could not be resolved: org.openid4java:openid4java:jar:0.9.6, org.openid4java:openid4java-consumer:jar:0.9.6, org.openid4java:openid4java-server:jar:0.9.6, org.openid4java:openid4java-server-JdbcServerAssociationStore:jar:0.9.6, org.openid4java:openid4java-consumer-SampleConsumer:jar:0.9.6, org.openid4java:openid4java-server-SampleServer:jar:0.9.6: Failure to find org.openid4java:openid4java:jar:0.9.6 in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced 
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:196) 

Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project org.openid4java:simple-openid:war:0.9.6: The following artifacts could not be resolved: org.openid4java:openid4java:jar:0.9.6, org.openid4java:openid4java-consumer:jar:0.9.6, org.openid4java:openid4java-server:jar:0.9.6, org.openid4java:openid4java-server-JdbcServerAssociationStore:jar:0.9.6, org.openid4java:openid4java-consumer-SampleConsumer:jar:0.9.6, org.openid4java:openid4java-server-SampleServer:jar:0.9.6: Failure 

Caused by: org.sonatype.aether.resolution.DependencyResolutionException: The following artifacts could not be resolved: org.openid4java:openid4java:jar:0.9.6, org.openid4java:openid4java-consumer:jar:0.9.6, org.openid4java:openid4java-server:jar:0.9.6, org.openid4java:openid4java-server-JdbcServerAssociationStore:jar:0.9.6, org.openid4java:openid4java-consumer-SampleConsumer:jar:0.9.6, org.openid4java:openid4java-server-SampleServer:jar:0.9.6: Failure to find org.openid4java:openid4java:jar:0.9.6 in 

我在這裏做錯了什麼或者是實際上從Maven存儲庫中缺少的罐子?

回答

4

我能夠加入<type>pom</type>到的pom.xml來解決這一問題。我在this thread的OpenID4Java谷歌組中找到了答案。

下面是谷歌的組中跟帖說:

我的意思是,你應該在你的 pom.xml中添加 「POM」 到openid4java的依賴 部分:

<dependency> 
     <groupId>org.openid4java</groupId> 
     <artifactId>openid4java-consumer</artifactId> 
     <!--artifactId>openid4java-server</artifactId--> 
     <!--artifactId>openid4java-infocard</artifactId--> 
     <!--artifactId>openid4java-xri</artifactId--> 
     <!--artifactId>openid4java</artifactId--> 
     <!--artifactId>openid4java-full</artifactId--> 
     <version>0.9.6</version> 
     <type>pom</type> <-----------------------This line can not be omitted. 
    </dependency> 

openid4java-consumer/openid4java-server/....的類型都是「pom」而不是「jar」。該jar文件是在由openid4java消費者/ openid4java服務器依賴openid4java-nodeps ...

+0

作爲一個總的maven noob,我無法完成這項工作。哪個pom確切需要編輯?存儲庫中或包含的示例包中包含哪一個? – Steven

1

產生的原因:org.sonatype.aether.resolution.DependencyResolutionException:下面的文物無法解析:org.openid4java:openid4java:罐子:0.9.6,org.openid4java:openid4java消費中:jar:0.9 .6,org.openid4java:openid4java-server:jar:0.9.6,org.openid4java:openid4java-server-JdbcServerAssociationStore:jar:0.9.6,org.openid4java:openid4java-consumer-SampleConsumer:jar:0.9.6,org .openid4java:openid4java-服務器SampleServer:罐子:0.9.6:未能找到org.openid4java:openid4java:罐子:0.9.6在

您需要可以添加<repository>含有這些文物項目或將它們安裝到您的本地存儲庫。

嘗試https://oss.sonatype.org/content/repositories/openid4java/(在MavenHowTo找到)

+0

如果我正確理解你(並記住我幾乎是Maven noob),那麼你建議我指定一個特定的Maven在線存儲庫來搜索Jars或者從我從openid4java的網站直接下載的jar並將它們放置在我的本地Maven存儲庫中。 在我看來,版本0.9.6的jar文件也從您建議的資源庫(oss.sonatype.org)中丟失,並且您在openid4java網站的MavenHowTo wiki頁面中找到該文件。那有意義的是罐子在那裏失蹤了嗎?我看到之前版本0.9.5的罐子。 – Justin

+0

關於手動將罐子安裝到我的本地存儲庫的其他建議是有道理的。我有一個單獨的jar(openid4java-0.9.6.jar),我從openid4java的網站下載了它,但似乎Maven試圖下載幾個不同的openid4java相關jar(openid4java-consumer,openid4java-server等)。我確實擁有了openid4java-consumer,openid4java-server等的類,所以我不確定它是否需要分解成幾個jar或什麼。 – Justin

+0

我想我會嘗試使用依賴的jar文件Maven能夠下載並使用openid4java-0.9.6.jar將其打包並查看讓我感興趣的地方。 對不起,有多條評論,但我跑出了房間。 :)非常感謝您的回覆 – Justin

1

這是我做過什麼,使其編譯和運行:

  1. 轉到您的M2或Maven中央存儲庫,
  2. org-> openID4java-> openID4java-> 0.9.6和編輯openid4java-0.9.6.pom文件,並添加甲醛,其不具有罐子依賴
  3. org-> openID4java-> openid4java-consumer-SampleConsumer-> 0.9.6並編輯openid4java-consumer-SampleConsumer-0.9.6.pom文件並將pom添加到工件openId-consumer
  4. org-> openID4java-> openid4java-openid4java-server-SampleServer-> 0.9.6並編輯openid4java-server-SampleServer-0.9.6.pom文件並將pom添加到openId-服務器的工件中
  5. org-> openID4java-> openid4java-server-JdbcServerAssociationStore-0.9.6並打開pom文件並將pom添加到openID服務器工件。

融合的Eclipse,然後右鍵單擊項目和Maven的工具,用戶Maven和更新相關性,你準備好了, ,直接編譯,你準備推出

1

另一種方式來解決Grails的依賴是添加Maven倉庫「https://oss.sonatype.org/content/repositories/openid4java/」,並將「openid4java-nodeps」作爲工件。

repositories { 
    grailsPlugins() 
    grailsHome() 
    grailsCentral() 
    mavenCentral()  
    mavenRepo "https://oss.sonatype.org/content/repositories/openid4java/" 
} 

dependencies { 
    runtime('mysql:mysql-connector-java:5.1.19', 
      'org.apache.httpcomponents:httpclient:4.2', 
      'org.openid4java:openid4java-nodeps:0.9.6') { excludes "xml-apis" } 
} 
0

請行家爲每depency openid4java-xxx安裝包失敗,因爲便接踵而來:

  1. 運行openid4java-0.9.6目錄

  2. 內Ant構建任務,然後執行:

    mvn install:install-file -DgroupId=org.openid4java -DartifactId=openid4java-consumer -Dversion=0.9.6 -Dpackaging=jar -Dfile=<<change_this_path_to>>build\openid4java.jar 
    
    mvn install:install-file -DgroupId=org.openid4java -DartifactId=openid4java-server -Dversion=0.9.6 -Dpackaging=jar -Dfile=<<change_this_path_to>>build\openid4java.jar 
    
    mvn install:install-file -DgroupId=org.openid4java -DartifactId=openid4java-server-JdbcServerAssociationStore -Dversion=0.9.6 -Dpackaging=jar -Dfile=<<change_this_path_to>>build\openid4java.jar 
    
    mvn install:install-file -DgroupId=org.openid4java -DartifactId=openid4java-consumer-SampleConsumer -Dversion=0.9.6 -Dpackaging=jar -Dfile=<<change_this_path_to>>build\openid4java.jar 
    
    mvn install:install-file -DgroupId=org.openid4java -DartifactId=openid4java-server-SampleServer -Dversion=0.9.6 -Dpackaging=jar -Dfile=<<change_this_path_to>>build\openid4java.jar 
    

而且應該這樣做!