当前位置: 首页 > 知识库问答 >
问题:

在scalaide中使用spark构建maven,从而导致执行异常

常小白
2023-03-14

我使用Scala IDE来创建一个带有spark的maven项目

1.我创建了一个跳过原型的 maven 项目,并添加了以下 pom 文件。

<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>com.nivi</groupId>
  <artifactId>testSpark</artifactId>
  <version>0.0.1-SNAPSHOT</version>

    <repositories>
    <repository>
      <id>cloudera</id>
      <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
    </repository>

    <repository>
      <id>general</id>
      <url>https://repo1.maven.org/maven2</url>
    </repository>

  </repositories> 


  <dependencies>
              <dependency>
                    <groupId>org.scala-lang</groupId>
                    <artifactId>scala-library</artifactId>
                    <version>2.10.6</version>
              </dependency>
              <dependency>
                     <groupId>org.apache.spark</groupId>
                     <artifactId>spark-core_2.10</artifactId>
                     <version>1.6.0-cdh5.8.2</version>
                     <scope>provided</scope>
              </dependency>
              <dependency>
                     <groupId>org.apache.spark</groupId>
                     <artifactId>spark-mllib_2.10</artifactId>
                     <version>1.6.0-cdh5.8.2</version>
                     <scope>provided</scope>
              </dependency>

              <dependency>
                    <groupId>org.apache.spark</groupId>
                    <artifactId>spark-hive_2.10</artifactId>
                    <version>1.6.0-cdh5.8.2</version>
                   <scope>provided</scope>
              </dependency>

              <dependency>
                    <groupId>org.scala-tools</groupId>
                    <artifactId>maven-scala-plugin</artifactId>
                    <version>2.15.2</version>
                   <scope>provided</scope>
              </dependency>
</dependencies>
        <build>
              <plugins>

                     <!-- mixed scala/java compile -->
                     <plugin>
                           <groupId>org.scala-tools</groupId>
                           <artifactId>maven-scala-plugin</artifactId>
                           <version>2.15.2</version>
                           <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>
                           <configuration> 
           <scalaVersion>2.10.6</scalaVersion> 
         </configuration> 
                     </plugin>
                     <plugin>
                           <artifactId>maven-compiler-plugin</artifactId>
                           <version>2.4</version>
                           <configuration>
                                  <source>1.8</source>
                                  <target>1.8</target>
                           </configuration>
                     </plugin>
                     <!-- for fatjar -->
                     <plugin>
                           <groupId>org.apache.maven.plugins</groupId>
                           <artifactId>maven-assembly-plugin</artifactId>
                           <version>2.4</version>
                           <configuration>
                                  <descriptorRefs>
                                         <descriptorRef>jar-with-dependencies</descriptorRef>
                                  </descriptorRefs>
                           </configuration>
                           <executions>
                                  <execution>
                                         <id>assemble-all</id>
                                         <phase>package</phase>
                                         <goals>
                                                <goal>single</goal>
                                         </goals>
                                  </execution>
                           </executions>
                     </plugin>
                     <plugin>
                           <groupId>org.apache.maven.plugins</groupId>
                           <artifactId>maven-jar-plugin</artifactId>
                           <version>2.4</version>
                           <configuration>
                                  <archive>
                                         <manifest>
                                                <addClasspath>true</addClasspath>
                                                <mainClass>fully.qualified.MainClass</mainClass>
                                         </manifest>
                                  </archive>
                           </configuration>
                     </plugin>
              </plugins>
              <pluginManagement>
                     <plugins>
                           <!--This plugin's configuration is used to store Eclipse m2e settings 
                                  only. It has no influence on the Maven build itself. -->
                           <plugin>
                                  <groupId>org.eclipse.m2e</groupId>
                                  <artifactId>lifecycle-mapping</artifactId>
                                  <version>1.0.0</version>
                                  <configuration>
                                         <lifecycleMappingMetadata>
                                                <pluginExecutions>
                                                       <pluginExecution>
                                                              <pluginExecutionFilter>
                                                                     <groupId>org.scala-tools</groupId>
                                                                     <artifactId>
                                                                           maven-scala-plugin
                                                                     </artifactId>
                                                                     <versionRange>
                                                                           [2.15.2,)
                                                                     </versionRange>
                                                                     <goals>
                                                                           <goal>compile</goal>
                                                                           <goal>testCompile</goal>
                                                                     </goals>
                                                              </pluginExecutionFilter>
                                                              <action>
                                                                     <execute></execute>
                                                              </action>
                                                       </pluginExecution>
                                                </pluginExecutions>
                                         </lifecycleMappingMetadata>
                                  </configuration>
                           </plugin>
                     </plugins>
              </pluginManagement>

  </build>
</project>

我在配置中添加了scala特性。

我在属性中添加了src/main/scala文件夹——

我在项目属性里设置了java编译器1.8和scala编译器2.10.6带jvm 1.8。

但是我在maven全新安装时得到了以下错误:

在此处输入图像描述

共有2个答案

郎吉星
2023-03-14

> < li>

你能试试最近版本的scala插件吗?(是你用的那个的后继,我是两个的作者)

<plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    <version>3.3.2</version>
</plugin>

(见http://davidb.github.io/scala-maven-plugin/example_java.html)

太叔俊侠
2023-03-14

转到此位置 c:\users\Nivedita.m2\存储库\组织\apache\hadoop\hadoop-common\2.6.0-cdh5.8.2,然后尝试删除 hadoop-common-2.6.0-cdh5.8.2.jar文件,然后再次进行 maven 构建。

 类似资料:
  • 我正试图通过gradle(OS X,el kapitan)从源代码构建junit 5。签出:git clonehttps://github.com/junit-team/junit5.git 运行生成命令:gradlew clean assemble(或install) 在这两种情况下,我都得到: 有什么提示吗?线等回答

  • 问题内容: 我试图使用maven为名为“ logmanager”的小型家庭项目生成可执行jar,如下所示: 如何使用Maven创建具有依赖项的可执行JAR? 我将此处显示的代码段添加到pom.xml中,并运行了mvn assembly:assembly。它在logmanager / target中生成两个jar文件:logmanager-0.1.0.jar和logmanager-0.1.0-jar

  • 我制作了一个Java应用程序,它使用Maven、JavaFX和一些其他依赖项。以前,构建一个可执行jar很容易,但由于Java11是模块化的,不包含JavaFX,所以我无法构建一个工作的jar。 我已经尝试了很多事情,但我不知道我现在应该做什么。 我的pom。xml 我试图构建包含所有依赖项的工件,但在运行(java-jar)时出现了一个错误: 编辑 我曾尝试使用Jlink构建一个包含JavaFX

  • 我运行以下命令(它是一个lib项目,但我也在常规项目中得到它):

  • 您好,我已经创建了一个带有gradle配置的spring boot项目,其中包含身份验证、社交登录等常见功能,我想从gradle项目生成可执行的jar文件并生成为依赖项,这样我就可以将其导入到另一个spring gradle或maven项目中,以便访问包含的依赖项的RESTendpoint (项目A:希望成为图书馆) 建筑格拉德尔 项目还包含endpoint,如 它使用gradle build命令

  • 我试图理解为什么下面的代码打印“我不应该被打印!!" try块中的代码抛出一个错误,当它的errorAction变量被设置为stop时,Ppowershell将执行相应的catch块。 在catch中,测试函数调用将失败(因为测试函数参数属性validateSet不包括“facdfsd”)并抛出明显不终止的异常:ParameterArgumentValidationError 我现在期望执行在测试