pom.xml 中存在依赖项错误(缺少工件...)

问题描述 投票:0回答:9

一位朋友给了我一个 Maven 项目,我正在尝试在我的计算机上本地运行该项目。我在 Eclipse 中所做的一切,我选择了:

文件 -> 导入 -> 现有 Maven 项目

此后,该项目在我的

pom.xml
中显示了 4 个错误(缺少工件..):

enter image description here

我尝试删除

.m2
文件夹的内容,然后在 Eclipse 中单击我的项目并选择“运行方式”->“Maven clean”,然后选择“运行方式”->“Maven 安装”。但我仍然有同样的错误。我是 Spring 新手,所以我不知道还能做什么。

编辑:

当我尝试执行:run as/maven install 时,这就是我的控制台所说的:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building DataLayer 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for javax.persistence:javax.persistence:jar:1.0.0 is missing, no     dependency information available
[WARNING] The POM for hibernate-core:hibernate-core:jar:4.2.1.Final is missing, no     dependency information available
[WARNING] The POM for hibernate-commons-annotations:hibernate-commons-annotations:jar:4.0.1.Final is missing, no dependency information available
[WARNING] The POM for jboss-logging:jboss-logging:jar:3.1.0.CR2 is missing, no dependency information available
[WARNING] The POM for jta:jta:jar:1.1 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.065s
[INFO] Finished at: Wed Aug 07 11:41:45 VET 2013
[INFO] Final Memory: 4M/90M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project DataLayer: Could not resolve dependencies for     project SocialManager:DataLayer:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: javax.persistence:javax.persistence:jar:1.0.0, hibernate-core:hibernate-core:jar:4.2.1.Final, hibernate-commons-annotations:hibernate-commons-annotations:jar:4.0.1.Final, jboss-logging:jboss-logging:jar:3.1.0.CR2, jta:jta:jar:1.1: Failure to find javax.persistence:javax.persistence:jar:1.0.0 in http://repository.jboss.org/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of JBoss repository has elapsed or updates are forced -> [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.

编辑2:这是我完整的pom.xml:https://dl.dropboxusercontent.com/u/31349296/pom.xml当我尝试将代码粘贴到此处时,它看起来非常糟糕。

maven spring-mvc
9个回答
26
投票

好像很多依赖都不正确。

enter image description here

在此处下载整个 POM

寻找正确依赖项的好地方是 Maven Repository 网站。


9
投票

我知道这是一个老问题。但我希望我的回答能对某人有所帮助。我遇到了同样的问题,我认为问题是它在本地存储库中找不到这些 .jar 文件。所以我所做的就是将以下代码添加到我的 pom.xml 中并且它起作用了。

<repositories>
  <repository>
      <id>spring-milestones</id>
      <name>Spring Milestones</name>
      <url>https://repo.spring.io/libs-milestone</url>
      <snapshots>
          <enabled>false</enabled>
      </snapshots>
  </repository>
</repositories>

1
投票

这意味着 Maven 无法从存储库下载工件。 以下步骤将对您有所帮助:

  1. 转到存储库浏览器并检查工件是否存在。
  2. 检查 settings.xml 以查看是否指定了正确的存储库。
  3. 检查代理设置。

1
投票

这是一个很晚的答案,但这可能会有所帮助。我去了这个链接并搜索了ojdbc8(我试图添加jdbc oracle驱动程序) 当点击结果时,会显示这样的注释:

enter image description here

我单击了注释中的链接,并提到了正确的依赖项,如下所示 enter image description here


1
投票

我在尝试解决 Maven/Java/Selenium/Cucumber 项目的“单独问题”时遇到了这个问题。 出于某种原因,即使 com.google.guava 代码段的 Maven repo 页面中有此内容,我也通过从中删除包来解决此问题。 <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>31.1-jre</version> <!--type>bundle</type--> </dependency>

确切的错误消息:

Missing artifact com.google.guava:guava:bundle:31.1-jre

我还发现这篇文章很有帮助。
如何调试 Maven 和 Gradle 中的依赖冲突


0
投票


0
投票

首先检查项目的结束标签。它应该放在所有依赖标记关闭之后。这样我解决了我的错误。 ——苏什 快乐编码:)


0
投票

连接到 JDK 后,pom.xml 问题就解决了。


0
投票

我找到了一个可靠的解决方案 [1]:

https://i.sstatic.net/pBNFgBDf.png

我在 eclipse 中找到了最好的解决方案
第1步:在Eclipse IDE中

->Windows -> 首选项 -> 左侧单击 maven 取消选中 Offline ,取消选中 debug 输出 检查下载工件源, 检查下载工件 Javadoc ->申请,申请并关闭

点击maven项目 -> maven -> 更新项目 -> 离线时取消勾选 -> 选中“强制更新快照/发布” 按确定

问题成功解决 我已经尝试了太多天了,而且 卸载了eclipse但是经过这个设置 我已经解决了这个问题

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.