Maven“无法解析openid4java的依赖关系”

时间:2011-06-30 23:39:57

标签: java maven openid4java

总结:
运行“mvn war:war”失败,错误包括:
“以下工件无法解析:org.openid4java:openid4java:jar:0.9.6”。

我认为我是Maven noob,但我看到其他人已经发布到openid4java网站,从maven central发出jars are missing来表示openid4java。

详细说明:
我正在尝试通过运行最新版本的openid4java(0.9.6.662)中包含的Simple-OpenID示例应用程序来熟悉openid4java。

根据自述“此演示需要 apache Maven2来构建”。自述文件还指出“mvn war:war任务应该创建一个war文件,可以通过复制war文件来部署。”

到目前为止,我一直在使用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存储库中实际上缺少的罐子?

5 个答案:

答案 0 :(得分:4)

我可以通过将<type>pom</type>添加到pom.xml来解决此问题。我在this thread中的OpenID4Java google组中找到了答案。

以下是Google群组中的帖子所说的内容:

  

我的意思是你应该添加   依赖于“pom”   你的openid4java部分   pom.xml中:

   <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-nodeps中,由openid4java-consumer / openid4java-server依赖...

答案 1 :(得分:1)

  

引起:org.sonatype.aether.resolution.DependencyResolutionException:无法解析以下工件: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:找不到org.openid4java:openid4java:jar:0.9.6 in

您需要向包含这些工件的项目添加<repository>,或者将它们安装到本地存储库。

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

答案 2 :(得分:1)

这就是我为编译和运行而做的事情:

  1. 转到您的m2或maven中央存储库,
  2. org-&gt; openID4java-&gt; openID4java-&gt; 0.9.6并编辑openid4java-0.9.6.pom文件并将pom添加到没有jar的依赖项
  3. org-&gt; openID4java-&gt; openid4java-consumer-SampleConsumer-&gt; 0.9.6并编辑openid4java-consumer-SampleConsumer-0.9.6.pom文件并将pom添加到openId-consumer的工件中
  4. org-&gt; openID4java-&gt; openid4java-openid4java-server-SampleServer-&gt; 0.9.6并编辑openid4java-server-SampleServer-0.9.6.pom文件并将pom添加到openId-server的工件中
  5. org-&gt; openID4java-&gt; openid4java-server-JdbcServerAssociationStore-0.9.6并打开pom文件并将pom添加到openID-server工件中。
  6. 融合Eclipse,然后右键单击项目和maven并更新您准备好的依赖项, 对于maven工具用户,直接编译并准备好滚动

答案 3 :(得分: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" }
}

答案 4 :(得分:0)

每个依赖项openid4java-xxx的maven安装包都失败了,如下所示:

  1. openid4java-0.9.6目录

  2. 中运行ant build任务
  3. 然后执行:

    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
    
  4. 那应该这样做!