Maven - 包 graphstream 不存在

Maven - package graphstream does not exist

我在 Maven 项目中的 pom.xml 文件中添加了 'graphstream' 依赖项,如下所示:

<dependency>
     <artifactId>gs-core</artifactId>
     <groupId>org.graphstream</groupId>
     <version>2.0</version>
</dependency>

然后我尝试将 'graphstream' 导入我的 java 文件:

import org.graphstream.*;

但是当我 运行 mvn install 我收到以下错误

包org.graphstream不存在

我做错了什么?

我检查了 source code: there is no package org.graphstream really. There is a folder org/graphstream that contains other folders. You may use import org.graphstream.graph.*; as this is a real package. You probably want to recursively import everything, but it's not how Java works. I give you a quote from this conversation:

There aren't really "sub-packages." The JLS actually uses that term, but I don't know why. There's no real hierarchy, other than the one on the filesystem and the logical one implied by the names. As far as Java is concerned, the packages have no relation to each other.

这是我的虚拟代码,导入在您的项目中应该如何显示:

import org.graphstream.graph.*;

public class Test {

    public static void main(String[] args) {
        System.out.printf("Import works: %s", Graph.class);
    }
}

希望它能回答您的问题。我还用我的沙盒创建了一个 github repo。请检查项目根目录中的代码和 运行 mvn compile exec:java -Dexec.mainClass="org.test.Test" 。如果它不起作用,请告诉我输出结果。