我想從使用eclipse mars的maven項目創建一個可執行文件.jar。該項目本身可以在https://github.com/jsprit/jsprit導出jsprit maven項目到一個可執行的jar
到目前爲止,我已經成功地將jsprit導入eclipse作爲maven項目,並且能夠將示例作爲Java應用程序運行。
我還沒有成功將它導出爲可執行jar。假設我想導出SimpleExample.java。我已經創建了.jar但如果我嘗試運行jsprit-例子-1.6.2-SNAPSHOT-JAR-與-dependencies.jar我收到以下錯誤信息:
Error: Could not find or load main class jsprit.examples.SimpleExample
位於pom.xml中下jsprit-例子是以下幾點:
<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">
<parent>
<groupId>jsprit</groupId>
<artifactId>jsprit</artifactId>
<version>1.6.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jsprit-examples</artifactId>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>enforce</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>jsprit.examples.SimpleExample</mainClass>
</manifest>
</archive>
<descriptors>
<descriptor>src/main/resources/assemblies/jar-with-dependencies.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<repositories>
<repository>
<id>jsprit-snapshots</id>
<url>https://github.com/jsprit/mvn-rep/raw/master/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jsprit-instances</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jsprit-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jsprit-analysis</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
其他的都是在GitHub的庫相同。 我在jsprit-examples上運行'Maven Build ...'。在'編輯配置 - >目標'下,我做了'清理軟件包組合:單一'。
這是我第一次使用maven構建經驗,所以對於有maven經驗的人來說,這可能是一個非常簡單的問題。
謝謝!