2017-05-06 64 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