2017-05-06 53 views
0

我目前正在使用Repast进行一个模拟项目。这是一个自定义的eclipse版本,内置了用于实际仿真的库。从定制Eclipse版本添加依赖到Maven

我现在想做出一个Maven项目。然而,我无法弄清楚,如何将Repast-libraries包含到我的pom.xml中,因为mvnrepository中没有条目,我的项目文件夹中也没有这些库。他们都来自就餐插件并驻留我Eclipse安装中,你可以看到如下:

Package Explorer View

这是我的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项目中? 每当我运行maven构建过程时,生成的JAR都会以“NoClassDefFoundErrors”结束。当我用WinRaR打开JAR文件时,我发现重新装入的库不在那里。

有没有人有一个想法如何解决这个问题?提前致谢!

+0

快速谷歌搜索发现这一点:https://sourceforge.net/p/repast/mailman/message/34207780/ – metame

+0

是的,我知道这个职务。但这是另一种方式。他问,如何将maven依赖关系放入餐厅,而不是将maven餐具放入maven build。 – Johannes

回答

0

在本SourceForge forum引用:

包含在Eclipse中的Maven管理依赖关系的罐子不 包括所使用的类路径由默认的启动器与 备份项目相关联。因此,当存在Maven 依赖关系时启动项目将导致NoClassDefFoundError,因为Repast通过类路径搜索 以查找注释。

的解决方案如下:

加入了Eclipse的Maven管理 依赖的启动文件(位于发射器/ [项目名称] Model.launch)。以下行添加到类路径条目:

<listEntry value="&lt;?xml version=&quot;1.0&quot; 
encoding=&quot;UTF-8&quot; 
standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry 
containerPath=&quot;org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER&quot; 
path=&quot;3&quot; type=&quot;4&quot;/&gt;&#13;&#10;"/> 
+0

是的,我知道这个帖子。但这是另一种方式。他问,如何将maven依赖关系放入餐厅,而不是将maven餐具放入maven build – Johannes