【问题标题】:Missing artifact net.sf.jung:jung2:jar:2.0缺少工件 net.sf.jung:jung2:jar:2.0
【发布时间】:2015-03-26 08:23:54
【问题描述】:

jung2 位于 maven 存储库中,herehere

但是我的 Eclipse 没有发现它:

代码在这里:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>tests.jung</groupId>
    <artifactId>TryJung</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>

        <dependency>
            <groupId>net.sf.jung</groupId>
            <artifactId>jung2</artifactId>
            <version>2.0</version>
        </dependency>



    </dependencies>
</project>

更新

抱歉,无法接受有关依赖类型的答案,因为它不完整。 jung 依赖的代码直接取自 Maven 仓库:

所以,我需要解释一下,为什么取自存储库站点的代码实际上不起作用。

这里发生了什么,谁“有罪”?

【问题讨论】:

  • 问题只是你正在处理的工件是pom file 而不是 jar 文件。这就是消息的原因。

标签: java eclipse maven jung2


【解决方案1】:

只是偶然发现了同样的问题。显然,这些是纯粹用于构建/记录(所有)子项目(或 maven 中的子模块)的 pom 文件(在本例中为 jung2)

它们不能以有用的方式用作依赖项

实际上,您可以使用 &lt;type&gt;pom&lt;/type&gt; 依赖它们,但只会包含该 pom 的依赖关系,但 不是它是模块。

查看这里以获得更完整的解释: How to use POMs as a dependency in Maven?

【讨论】:

    【解决方案2】:

    如前所述,您正在处理一个 pom 文件。从某种意义上说,这是正确的,但如果你想编译,你需要在依赖项部分添加实际的 jar,例如:

    <dependencies>
    
        <dependency>
            <groupId>net.sf.jung</groupId>
            <artifactId>jung2</artifactId>
            <version>${jung.version}</version>
            <type>pom</type>
        </dependency>
    
        <dependency>
            <groupId>net.sf.jung</groupId>
            <artifactId>jung-api</artifactId>
            <version>${jung.version}</version>
            <scope>compile</scope>
        </dependency>
    
        <dependency>
            <groupId>net.sf.jung</groupId>
            <artifactId>jung-visualization</artifactId>
            <version>${jung.version}</version>
            <scope>compile</scope>
        </dependency>
    
        <dependency>
            <groupId>net.sf.jung</groupId>
            <artifactId>jung-graph-impl</artifactId>
            <version>${jung.version}</version>
            <scope>compile</scope>
        </dependency>
    
        <dependency>
            <groupId>net.sf.jung</groupId>
            <artifactId>jung-algorithms</artifactId>
            <version>${jung.version}</version>
            <scope>compile</scope>
        </dependency>
    
        <dependency>
            <groupId>net.sf.jung</groupId>
            <artifactId>jung-io</artifactId>
            <version>${jung.version}</version>
            <scope>compile</scope>
        </dependency>
    
    </dependencies>
    

    别忘了在属性部分也定义版本属性:

    <properties>
        <jung.version>2.0.1</jung.version>
    </properties>
    

    希望这会有所帮助。

    【讨论】:

      【解决方案3】:

      问题只是您正在处理的工件是pom file,而不是 jar 文件。这就是消息的原因。

      【讨论】:

      • 为什么不是写“不正确的工件类型”,而是写“找不到工件”?
      • 工件类型默认为jar,这就是问题所在,这意味着您需要了解 Maven 的默认依赖项。
      • mvnrepository.com 网站的创建者需要了解这一点。他们可能不知道 maven 默认依赖项,因为他们在没有 pom 条目的情况下提供 pom 依赖项,请参阅我的更新。
      猜你喜欢
      • 1970-01-01
      • 2018-12-29
      • 2013-11-01
      • 2018-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多