2014-10-31 77 views
0

我有Eclipse Kepler,我已經安裝了Maven和Scala插件。我創建了一個新的Maven項目,並添加依賴Eclipse項目與Scala插件,Maven和Spark

的groupId:org.apache.spark 的artifactId:火花core_2.10 版本:1.1.0

http://spark.apache.org/downloads.html按照當前文檔,一切都很好, Scala 2.10的罐子也被添加到項目中。然後我在項目中添加了「Scala Nature」,這增加了Scala 2.11,並且最終出現以下錯誤

構建路徑中存在多個scala庫(C:/ Eclipse/eclipse-jee-kepler- SR2-win32-x86_64/plugins/org.scala-lang.scala-library_2.11.2.v20140721-095018-73fb460c1c.jar,C:/Users/fff/.m2/repository/org/scala-lang/scala-library/ 2.10.4 /階庫-2.10.4.jar)。 至少有一個版本不兼容。 請更新項目構建路徑,使其僅包含兼容的scala庫。

是否可以一起使用Spark(來自Maven)和Scala IDE插件?任何想法如何解決這個問題?

感謝您的幫助。問候

回答

2

總之,是的,這是可能的。

星火目前正在使用Scala的2.10,而最新的Scala IDE是2.10和2.11「發表交叉」。您需要選擇基於2.10的版本,即3.0.3。

然而,下一個主要版本,4.0,這是在發佈候選模式,具有多版本的支持。您可以創建一個Scala項目並選擇您想要使用的Scala版本(2.10或2.11)。如果你喜歡它,你可以嘗試一下。

+0

謝謝,這做到了。我爲該項目選擇了Scala 2.10,並且它工作正常。親切的問候 – Francesco 2014-10-31 10:14:47

0

您已經安裝了斯卡拉IDE插件,但一個項目的斯卡拉性質是僅使用,如果你在項目中包含Scala類。然而,Spark和Scala是一起工作的。確保你使用兼容版本。您可以在您的計算機上使用install scala,然後使用兼容的spark maven依賴項。

0

是你可以使用..我提供以下

<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/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.spark-scala</groupId> 
    <artifactId>spark-scala</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>${project.artifactId}</name> 
    <description>Spark in Scala</description> 
    <inceptionYear>2010</inceptionYear> 

    <properties> 
     <maven.compiler.source>1.8</maven.compiler.source> 
     <maven.compiler.target>1.8</maven.compiler.target> 
     <encoding>UTF-8</encoding> 
     <scala.tools.version>2.10</scala.tools.version> 
     <!-- Put the Scala version of the cluster --> 
     <scala.version>2.10.4</scala.version> 
    </properties> 

    <!-- repository to add org.apache.spark --> 
    <repositories> 
     <repository> 
      <id>cloudera-repo-releases</id> 
      <url>https://repository.cloudera.com/artifactory/repo/</url> 
     </repository> 
    </repositories> 

    <build> 
     <sourceDirectory>src/main/scala</sourceDirectory> 
     <testSourceDirectory>src/test/scala</testSourceDirectory> 
     <plugins> 
      <plugin> 
       <!-- see http://davidb.github.com/scala-maven-plugin --> 
       <groupId>net.alchim31.maven</groupId> 
       <artifactId>scala-maven-plugin</artifactId> 
       <version>3.2.1</version> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.13</version> 
       <configuration> 
        <useFile>false</useFile> 
        <disableXmlReport>true</disableXmlReport> 
        <includes> 
         <include>**/*Test.*</include> 
         <include>**/*Suite.*</include> 
        </includes> 
       </configuration> 
      </plugin> 

      <!-- "package" command plugin --> 
      <plugin> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <version>2.4.1</version> 
       <configuration> 
        <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> 
      <plugin> 
       <groupId>org.scala-tools</groupId> 
       <artifactId>maven-scala-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 

    <dependencies> 
     <dependency> 
      <groupId>org.apache.spark</groupId> 
      <artifactId>spark-core_2.11</artifactId> 
      <version>1.2.1</version> 
     </dependency> 
    </dependencies> 
</project> 
0

的POM有2種類型的星火JAR文件(只是看着名稱):

  • 名稱包括詞語「組件」而不是「核心」(具有內部的Scala)

  • 名稱包括單詞「核心」而不是「組件」(無Scala的內側)。

你應該通過「添加外部JAR」(你需要的版本)在您的構建路徑「芯」類型,因爲Scala的IDE已經塞到一個Scala的爲您服務。

或者,你可以利用SBT,並添加下面的相關(再次,要注意你所需要的版本):

libraryDependencies + =「org.apache.spark」%「火花core_2 .11「%」2.1.0「

然後,您不應該在構建路徑中強制包含任何火花JAR。

快樂火花:

扎爾

>