eclipse Maven 依赖项引用不存在的库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16548600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 20:29:49  来源:igfitidea点击:

Maven Dependencies references non existing library

eclipsemavenm2eclipsem2e

提问by user2196234

As stated above I have a problem regarding maven. In my current eclipse project I used maven for dependecy management and it worked fine until now.

如上所述,我有一个关于 maven 的问题。在我当前的 eclipse 项目中,我使用 maven 进行依赖管理,直到现在它都运行良好。

The project is not working anymore and it states that:

该项目不再工作,它指出:

Maven Dependencies references non existing library: 
  c:\.m2\repository\org\eclipse\lyo\oslc4j\core\oslc4j-core.1\oslc4j-core-1.1.jar'

If i check the folder there are files that have the same name as the jar but end on jar.lastUpdated.

如果我检查文件夹,则有与 jar 同名但以 jar.lastUpdated 结尾的文件。

I tried maven clean and maven update which did not work. The line in my pom.xml is marked red and states:

我试过 maven clean 和 maven update 都没有用。我的 pom.xml 中的行被标记为红色并指出:

Missing artifact org.eclipse.lyo.oslc4j.core:oslc4j-core:jar:1.1

This is the content of my pom.xml:

这是我的 pom.xml 的内容:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:/www.w3.org2001XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.or/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>rtc_oslc_common</groupId>
<artifactId>rtc_oslc_common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
  <sourceDirectory>src</sourceDirectory>
  <plugins>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.2</version>
      <configuration>
        <source>1.6</source>
        <target>1.6</target>
      </configuration>
    </plugin>
  </plugins>
</build>

This block is the one with the marker where it states the artifact is missing.

这个块是带有标记的块,它指出工件丢失。

<dependencies>
  <dependency>
    <groupId>org.eclipse.lyo.oslc4j.core</groupId>
    <artifactId>oslc4j-core</artifactId>
    <version>1.1</version>
  </dependency>
</dependencies>
</project>

I don't know why it is not just reloading the jars and instead stays in this weird state. Help very much appriaciated.

我不知道为什么它不只是重新加载罐子,而是停留在这种奇怪的状态。帮助非常appriaciated。

回答by chkal

Basically Maven is telling you that it cannot find the dependency you declared in your pom.xml. The fact that there is a file called *.jar.lastUpdatedmeans that Maven tried to download the dependency but wasn't able to fetch it.

基本上 Maven 告诉你它找不到你在 pom.xml 中声明的依赖项。有一个名为的文件的事实*.jar.lastUpdated意味着 Maven 尝试下载依赖项但无法获取它。

First you could try to completely delete the folder containing the *.jar.lastUpdatedand run the build again. Maven will then try to download the dependency again. Perhaps it was just a temporary error.

首先,您可以尝试完全删除包含 的文件夹*.jar.lastUpdated并再次运行构建。然后 Maven 将再次尝试下载依赖项。也许这只是一个暂时的错误。

But as this dependency is not available in Maven Central, you may have to add the corresponding repository to your pom.xml.

但是由于 Maven Central 中没有此依赖项,因此您可能需要将相应的存储库添加到您的 pom.xml 中。

回答by Brian White

Sometimes an officially stated dependency configuration is incorrect, too. For example, as of 2015-05-23 the Robolectricsite says...

有时,官方声明的依赖项配置也不正确。例如,截至2015 年 5 月 23日,Robolectric网站说...

<dependency>
   <groupId>org.robolectric</groupId>
   <artifactId>robolectric</artifactId>
   <version>3.0</version>
   <scope>test</scope>
</dependency>

... which gives the same error you describe. After banging my head for a while (of course this was the first time I've ever tried Maven), I ended up checking at Maven Central this URL: http://mvnrepository.com/artifact/org.robolectric/robolectric

...这给出了您描述的相同错误。在敲了一阵子之后(当然这是我第一次尝试 Maven),我最终在 Maven Central 上查看了这个 URL:http: //mvnrepository.com/artifact/org.robolectric/robolectric

Lo and behold, there is no version 3.0. Instead, there are versions "3.0-rc1" and "3.0-rc2". When I changed the dependency to "3.0-rc2", suddenly everything worked.

瞧,没有版本 3.0。相反,有版本“3.0-rc1”和“3.0-rc2”。当我将依赖项更改为“3.0-rc2”时,突然一切正常。

回答by CorningSun

I got the error like this:

我得到这样的错误:

The container 'Maven Dependencies' references non existing library 'G:\m2\repository\org\apache\tomcat\tomcat-embed\7.0.65\tomcat-embed-7.0.65.jar'

容器“Maven Dependencies”引用了不存在的库“G:\m2\repository\org\apache\tomcat\tomcat-embed\7.0.65\tomcat-embed-7.0.65.jar”

I found the tomcat-embedis actually a *.pomfile but not a *.jar

我发现tomcat-embed它实际上是一个*.pom文件而不是一个*.jar

<dependency>
  <groupId>org.apache.tomcat</groupId>
  <artifactId>tomcat-embed</artifactId>
  <version>7.0.65</version>
  <type>pom</type>
</dependency>

So I fixed this problem by:

所以我通过以下方式解决了这个问题:

  1. delete tomcat-embed-7.0.65.jar.lastUpdated
  2. copy a *.jarfile to dir G:\m2\repository\org\apache\tomcat\tomcat-embed\7.0.65\
  3. renamed to tomcat-embed-7.0.65.jar
  1. 删除 tomcat-embed-7.0.65.jar.lastUpdated
  2. 复制一个*.jar文件到目录G:\m2\repository\org\apache\tomcat\tomcat-embed\7.0.65\
  3. 重命名为 tomcat-embed-7.0.65.jar


But the other way to solve this problem?

但是用另一种方式解决这个问题呢?

回答by Ertu?rul KOMUT

Firstly, you repair, intenet problem. after that You must delete folders in maven repository folder. (For me C:\Users\ekomut.m2\repository)

首先,您修复互联网问题。之后,您必须删除 Maven 存储库文件夹中的文件夹。(对我来说 C:\Users\ekomut.m2\repository)

If you have an Internet problem, you can see "*.jar.lastUpdated" .If you don't delete this folder, maven can not try download again.

如果您有互联网问题,您可以看到“*.jar.lastUpdated”。如果您不删除此文件夹,maven 将无法再次尝试下载。