我正在尝试使用eclipse mars从maven项目创建可执行文件.jar。项目本身可以在https://github.com/jsprit/jsprit
上找到到目前为止,我已成功将jsprit导入eclipse作为maven项目,并且我能够将示例作为Java Application运行。
我还没有成功将它导出为可执行jar。假设我想导出SimpleExample.java。我创建了.jar但是如果我尝试运行jsprit-examples-1.6.2-SNAPSHOT-jar-with-dependencies.jar我收到以下错误消息:
错误:无法找到或加载主类jsprit.examples.SimpleExample
位于jsprit-examples下的pom.xml如下:
<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 ...'。在'Edit Configuration-&gt; Goals'下,我做了'clean package assembly:single'。
这是我第一次使用maven构建体验,因此对于有maven经验的人来说这可能是一个非常简单的问题。
谢谢!