0

我是使用 maven 的新手,我正在尝试运行 jsprit 库 github 上列出的“SimpleExample.java”,您可以在此处找到设置说明代码。

我根据我找到的一些maven教程设置了目录,POM的内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework</groupId>
    <artifactId>gs-maven</artifactId>
    <packaging>jar</packaging>
    <version>0.1.0</version>

    <dependencies> <!-- add this, if you don't have any dependency definitions yet -->
      <dependency>
        <groupId>jsprit</groupId>
        <artifactId>jsprit-core</artifactId>
        <version>1.6</version>
      </dependency>
      <dependency>
        <groupId>jsprit</groupId>
        <artifactId>jsprit-analysis</artifactId>
        <version>1.6</version>
      </dependency>
      <dependency>
        <groupId>jsprit</groupId>
        <artifactId>jsprit-instances</artifactId>
        <version>1.6</version>
      </dependency>
    </dependencies> <!-- add this, if you don't have any dependency definitions yet -->

    <repositories> <!-- add this, if you don't have any repository definitions yet -->
      <repository>
        <id>jsprit-releases</id>
        <url>https://github.com/jsprit/mvn-rep/raw/master/releases</url>
      </repository>
    </repositories> <!-- add this, if you don't have any repository definitions yet -->

    <build>
    </build>
</project>

运行 mvn compile -> mvn install -> mvn package 之后。我转到目标目录并在终端中运行以下命令:

java -cp gs-maven-0.1.0.jar test.SimpleExample

注意:我的项目名称是 test。运行此命令后,我收到以下错误。如果您知道如何解决此问题,请告知。谢谢。

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: jsprit/core/problem/vehicle/VehicleType
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: jsprit.core.problem.vehicle.VehicleType
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more
4

0 回答 0