2016-10-13 12 views
0

Eclipseで作成したscalaプロジェクトに取り組んでいます。 Whenerver私はスカラーファイルを変更すると、 "Error:メインクラスcom.sparkscala.MainExampleを見つけたり読み込めませんでした"というメッセージが反映されていません。Eclipse-maven- Scalaプロジェクトで自動コンパイルが機能しません

の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/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> 
       <executions> 
        <execution> 
         <goals> 
          <goal>compile</goal> 
          <goal>testCompile</goal> 
         </goals> 
         <configuration> 
          <args> 
           <arg>-make:transitive</arg> 
           <arg>-dependencyfile</arg> 
           <arg>${project.build.directory}/.scala_dependencies</arg> 
          </args> 
         </configuration> 
        </execution> 
       </executions> 
      </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> 
       <executions> 
        <execution> 
         <id>scala-compile-first</id> 
         <phase>process-resources</phase> 
         <goals> 
          <goal>add-source</goal> 
          <goal>compile</goal> 
         </goals> 
        </execution> 
        <execution> 
         <id>scala-test-compile</id> 
         <phase>process-test-resources</phase> 
         <goals> 
          <goal>testCompile</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

    <dependencies> 
     <!-- Scala and Spark dependencies --> 
     <dependency> 
      <groupId>org.scala-lang</groupId> 
      <artifactId>scala-library</artifactId> 
      <version>${scala.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.spark</groupId> 
      <artifactId>spark-core_2.10</artifactId> 
      <version>1.2.0-cdh5.3.1</version> 
     </dependency> 

    </dependencies> 
</project> 

答えて

1

これはScalaのコンパイラはV遅いと不気味である複雑な
です。それはあなたに問題をはっきりと伝えるのではなく、最後に良いコンパイルされたファイルを実行します。したがって、println( "Hello World")をやっている場合は、実際にコンパイルが行われているかどうかを確認するために "Hello Something Else"に変更するか、IDEが最後にコンパイルされた最後のファイルを選択するだけです。
さらに、pom.xmlが正しくありません。 私はEclipseのWindows - > Show View - > Problemsに行くことをお勧めします。あなたは間違いなくいくつかの問題を抱えています。最初に取り外します。きれいにして、ビルドしてもう一度実行
Sparkを使用する場合は、ScalaのバージョンがEclipseプロジェクトビルドパスのバージョンと一致することを確認する必要があります。 唯一の依存関係として正しいバージョンのSparkを持つ良いpom.xmlがあります。 Spark依存関係階層に既に含まれているので、Scalaライブラリ依存関係を追加する必要はありません。また、EclipseプロジェクトのビルドパスのScalaライブラリバージョンが、pom.xmlで提供しているものと同じであることを確認してください。つまり、2.11.x >>

<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> 
関連する問題