2014-04-05 49 views
0

我有2個項目,一個maven java和另一個maven Scala。Java和Scala不能一起工作

scala是一個庫,我想在我的Java應用程序中使用。

我有以下依賴性在兩種:

<dependency> 
      <groupId>org.scala-lang</groupId> 
      <artifactId>scala-compiler</artifactId> 
      <version>2.9.0-1</version> 
      <scope>compile</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.scala-lang</groupId> 
      <artifactId>scala-library</artifactId> 
      <version>2.9.0-1</version> 
     </dependency> 

和作爲谷歌搜索發現,這行家-階-插件在兩個應用程式

<plugin> 
       <groupId>org.scala-tools</groupId> 
       <artifactId>maven-scala-plugin</artifactId> 
       <version>2.14.3</version> 
       <configuration> 
        <charset>UTF-8</charset> 
        <jvmArgs> 
         <jvmArg>-Xmx1024m</jvmArg> 
        </jvmArgs> 
       </configuration> 
       <executions> 
        <execution> 
         <id>compile</id> 
         <goals> 
          <goal>compile</goal> 
         </goals> 
         <phase>compile</phase> 
        </execution> 
        <execution> 
         <id>test-compile</id> 
         <goals> 
          <goal>testCompile</goal> 
         </goals> 
         <phase>test-compile</phase> 
        </execution> 
        <execution> 
         <phase>process-resources</phase> 
         <goals> 
          <goal>compile</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 

在行家中指定兩個&目標源是Java 1.6和我使用Netbeans(甚至嘗試從命令行,但沒有使用)

我構建了scala項目,然後標記系統依賴cy在Maven Java項目中使用它。

逸岸,我使用的是鵝解析器(斯卡拉項目 - https://github.com/jiminoc/goose

但每當我運行java項目/文件,我得到ClassNotFoundException解析器類。

嘗試了幾個小時,但沒有成功。

請幫忙。

此外,提及我已經嘗試建設與斯卡拉版本2.10.4但它也有同樣的問題。

+0

對於其他人登陸這裏,我最終使用'Eclipse Juno 4.2'和'm2e','scala-ide'和''''安裝了scala插件的maven支持。我仍然遵循相同的規則,構建了'scala',並將其用作Maven Java項目中的依賴項。我相信這個問題與版本控制或丟失的罐子有關。 –

回答

0

我構建了scala項目,然後在maven java項目中標記了一個系統依賴項。

System dependencies

依賴與觀測系統始終可用和倉庫沒有擡起頭來。它們通常用於告知Maven有關由JDK或VM提供的依賴關係。

由於您的斯卡拉項目不被JDK或VM提供的,它不是一個系統的依賴。如果您有兩個Java項目,則會遇到完全相同的問題。請刪除<scope>system</scope>

+0

我已經指定了使用的jar,因此也指定了'system'作用域。我不認爲刪除'系統'範圍,會讓我指定要使用的jar。 –