摘要:
运行“mvn war:war”失败,并显示以下错误:
“无法解析以下工件:org.openid4java:openid4java:jar:0.9.6”。

我认为我是Maven新手,但我发现其他人已经从Maven中心发布到openid4java网站,声明jars are missing为openid4java。

详细信息:
我正在尝试通过运行最新版本的openid4java(0.9.6.662)中包含的Simple-OpenID示例应用程序来快速掌握openid4java。

根据自述文件“此演示需要使用Apache Maven2进行构建”。自述文件还指出“mvn 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存储库中实际上缺少了jar?

最佳答案

通过将<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 ...

10-06 13:40