我当前使用Repast在一个仿真项目中工作。这是一个自定义的日食版本,带有内置库的实际模拟。
我现在想从中做一个小事。但是,我不知道如何将pom.xml的repast-libraries包括在mvnrepository上,我的项目文件夹中的库中均未包含库。它们都来自Repast插件,并驻留在我的Eclipse安装中,如下所示:
软件包Explorer视图
这就是我的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">
<modelVersion>4.0.0</modelVersion>
<groupId>Simulation</groupId>
<artifactId>Simulation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Simulation</name>
<url>http://maven.apache.org</url>
<build>
<sourceDirectory>src</sourceDirectory>
<outputDirectory>bin</outputDirectory>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>simulation.app.UserMain</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- some other dependencies that are required -->
</dependencies>
</project>
我的类路径中的相应条目是:
<classpathentry kind="con" path="REPAST_SIMPHONY_SUPPORT"/>
但是如何将其放入我的小项目中?每当我运行Maven构建过程时,生成的JAR都会用" NoclassDeffoundErrors"终止。当我用Winrar打开Jar-File时,我看到Repast库不在那里。
有人知道如何解决这个问题吗?预先感谢!
这是当您的代码依赖的类文件所依赖的类文件时引起的,并且在编译时存在,但在运行时找不到。在您的构建时间和运行时类中寻找差异。
您可以参考此链接:https://dzone.com/articles/how-resolve-0
https://dzone.com/articles/how-corlove-1
,如此SourceForge论坛中所述:
eclipse maven托管依赖性中包含的罐子不是 包含在与A相关的默认启动器使用的类Path中 repast项目。因此,在有Maven时启动该项目 依赖性将导致NoclassDeffoundError在repast搜索时 通过班级路径寻找注释。
解决方案如下:
添加Eclipse Maven管理启动文件的依赖项(位于发射器/[项目名称]中model.launch(。将以下行添加到classpath条目:
<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
containerPath="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"
path="3" type="4"/> "/>