构建Scala的Maven项目_风行者之倾覆天下的博客-程序员宅基地

技术标签: Maven  scala  spark  Scala  maven  Spark  

sparkscala项目Maven构建和使用

一、使用

spark-sql使用

spark-sql --master yarn --num-executors 30 --executor-memory 12g

二、建立项目

1.建立Maven项目:java文件夹 重命名为scala文件夹

2.修改xxx.xml配置

3.删除./idea下文件 scala_compier.xml的行<parameter value="-make:transitive" />,edit configuration里配置VM options:

 -Dspark.master=local -Dspark.master=local[k]-Dspark.master=local[*]

local 本地单线程

local[K] 本地多线程(指定K个内核)

local[*] 本地多线程(指定所有可用内核)

spark://HOST:PORT 连接到指定的 Spark standalone cluster master,需要指定端口。

mesos://HOST:PORT 连接到指定的 Mesos 集群,需要指定端口。

yarn-client客户端模式 连接到 YARN 集群。需要配置 HADOOP_CONF_DIR

yarn-cluster集群模式 连接到 YARN 集群。需要配置 HADOOP_CONF_DIR


4.配置.xml文件如下


<?xml version="1.0" encoding="UTF-8"?>
<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>rec.spark</groupId>
    <artifactId>recoment-model</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>${project.artifactId}</name>
    <description>My scala app</description>
    <inceptionYear>2016</inceptionYear>
    <licenses>
        <license>
            <name>My License</name>
            <url>http://....</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <encoding>UTF-8</encoding>
        <scala.version>2.11.8</scala.version>
        <scala.compat.version>2.11</scala.compat.version>
    </properties>


    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${scala.version}</version>
        </dependency>

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-compiler</artifactId>
            <version>${scala.version}</version>
        </dependency>

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-reflect</artifactId>
            <version>${scala.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.11</artifactId>
            <version>2.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-mllib_2.11</artifactId>
            <version>2.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-streaming_2.11</artifactId>
            <version>2.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.scalanlp</groupId>
            <artifactId>breeze-viz_2.11</artifactId>
            <version>0.12</version>
        </dependency>

        <dependency>
            <groupId>com.github.scopt</groupId>
            <artifactId>scopt_2.11</artifactId>
            <version>3.3.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-hive_2.10</artifactId>
            <version>1.3.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <version>2.7.2</version>
        </dependency>

        <dependency>
            <groupId> org.apache.cassandra</groupId>
            <artifactId>cassandra-all</artifactId>
            <version>0.8.1</version>

            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.specs2</groupId>
            <artifactId>specs2-core_${scala.compat.version}</artifactId>
            <version>2.4.16</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_${scala.compat.version}</artifactId>
            <version>2.2.4</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>src/main/scala</sourceDirectory>
        <testSourceDirectory>src/test/scala</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.2.0</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.18.1</version>
                <configuration>
                    <useFile>false</useFile>
                    <disableXmlReport>true</disableXmlReport>
                    <includes>
                        <include>**/*Test.*</include>
                        <include>**/*Suite.*</include>
                    </includes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>



版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/haramshen/article/details/53215999

智能推荐

迷宫问题(广搜 bfs)_小黑-lcg的博客-程序员宅基地

迷宫问题 Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)Total Submission(s) : 63 Accepted Submission(s) : 38Problem Description定义一个二维数组: int maze[5][5] = {

oracle 查看log档,ORACLE报警日志如何查看_六七北樾的博客-程序员宅基地

目得:首先了解什么是外部表,与其它表的区别,建立一个简单的外部表(主要看操作过程),最后我们用外部表查看ORACLE报警日志1.了解oracle外部表外部表定义:结构被存放在数据字典,而表数据被放在OS文件中的表作用:在数据库中查询OS文件的数据,还可以将OS文件数据装载到数据库中与其它表的区别:在外部表上不能执行DML操作,也不能在外部表上建索引,只能执行select操用2.建一个简单的外部表1..._oracle log

初学Python 浅谈入门篇-程序员宅基地

主要是写给想学python的同学初学Python那些事1. 什么是python2. python怎么运行2.1 下载python(编程环境)2.2 下载pycharm(开发工具)3. 学python1. 什么是pythonPython是一种跨平台的计算机程序设计语言。一位名叫Guido van Rossum的大佬在90年代开发出来的一门编程语言。(学习不能忘了本,饮水思源,学习Python...

函数封装:Ajax发送http请求(get&post)_将函数封装成http服务-程序员宅基地

ajax_tool.js:// 方法:ajax get 五部曲function ajax_get(url,data) { // 异步对象 var ajax = new XMLHttpRequest(); // url 方法 // 如果是get发送数据 发送的格式为 xxx.php?name=jack&age=18 // 所以 这里 需要拼接 url if (data)..._将函数封装成http服务

Log4J日志配置详解-程序员宅基地

今天群里一个哥们问一个问题:我想先控制每天日志的大小 比如10个1M的 这个是我最初使用的log4j配置文件里的内容log4j.appender.RF=org.apache.log4j.DailyRollingFileAppenderlog4j.appender.RF.File=./log/log.txtlog4j.appender.RF.DatePattern='.'yyyy-M..._log4j日志配置详解

window版本下postgreSQL备份数据库提示pg_dump版本问题_windows版pg数据库报错pg_dump: [归档 (db)] 与数据库 "myais" 联接失-程序员宅基地

问题背景阿里云服务器上安装了pg12然后突然有一天数据不能备份了,报错提示如下所示:pg_dump: �������汾: 12.2; pg_dump �汾: 9.6.14pg_dump: ��Ϊ�������汾��ƥ�����ֹ解析:上面错误大多数是乱码,但是恰恰一个关键点提醒了我。其一是pg-dump与两个版本号12.2和9.6.14然后我猜测可能是我服务上同时安装了两个版本的pg造成数据库备份时候选择pg-dump出错了。其实开始也饶了很大一个远路,就是去升级pg-dump,但是网上没有_windows版pg数据库报错pg_dump: [归档 (db)] 与数据库 "myais" 联接失败: fe_send

随便推点

MATLAB 求系统的单位冲击响应及单位阶跃响应-程序员宅基地

MATLAB 求系统的单位冲击响应及单位阶跃响应题目描述:某系统满足的微分方程为$y^{''}(t)+4y^{'}(t)+3y(t)=2f^{'}(t)+f(t)$,求系统的单位冲击响应.impulse函数impulse函数可以求得系统的单位冲击响应,参数为sys和t,其中sys为系统对应的微分方程,t为持续时间.sys变量由tf函数生成,其参数为输入部分的方程系数矩阵和响应部分的..._matlab求系统单位冲激响应

Warning: Permanently added ‘gitee.com,212.63.72.83‘ (ECDSA) to the list of known hosts.解决办法_warning: permanently added 'gitee.com,212.64.63.21-程序员宅基地

hexo部署博客到码云出现问题填写完ssh密匙后,上传出现:Warning: Permanently added ‘gitee.com,212.64.62.183’ (ECDSA) to the list of known hosts.解决办法: 重新配置git用户名邮箱git config --global user.name "你的账号"git config --global user.email "你邮箱地址"..._warning: permanently added 'gitee.com,212.64.63.215' (ecdsa) to the list of

OpenGL核心技术之SSAO讲解(四)_rsm ssao opengl-程序员宅基地

笔者介绍:姜雪伟,IT公司技术合伙人,IT高级讲师,CSDN社区专家,特邀编辑,畅销书作者,国家专利发明人;已出版书籍:《手把手教你架构3D游戏引擎》电子工业出版社和《Unity3D实战核心技术详解》电子工业出版社等。CSDN视频网址:http://edu.csdn.net/lecturer/144 在前面几篇博客介绍了SSAO的系列讲解,下面再给读者介绍深度值重构SSAO技术,也是在原有SSAO_rsm ssao opengl

Tensorflow出现Variable Actor/eval0/l1/kernel already exists, disallowed._valueerror: variable layers/fc0/kernel already exi_醉一心的博客-程序员宅基地

参考链接:https://blog.csdn.net/weixin_43283397/article/details/103289928?spm=1001.2014.3001.55061.问题描述Spyder或者Jupyter中重复运行Tensorflow的代码,会出现变量已经存在的问题。这是因为这些编辑器都会自动保存变量。具体错误描述:ValueError: Variable Actor/eval0/l1/kernel already exists, disallowed. Did you ._valueerror: variable layers/fc0/kernel already exists, disallowed. did you m

VC中,编译工具条内的Debug与Release选项是什么含义?_打开工程编译 64 位 release 是什么意思-程序员宅基地

Debug 通常称为调试版本,它包含调试信息,并且不作任何优化,便于程序员调试程序。Release 称为发布版本,它往往是进行了各种优化,使得程序在代码大小和运行速度上都是最优的,以便用户很好地使用。Debug带有大量的调试代码,运行时需要相应的运行库,发布模式程序紧凑不含有调试代码和信息,直接可以运行(如果不需要运行库)_打开工程编译 64 位 release 是什么意思

如何使用Mysqldump备份和还原MySQL数据库_mysqldump --database-程序员宅基地

本教程介绍如何使用 mysqldump 实用程序从命令行备份和还原 MySQL 或 MariaDB 数据库。mysqldump 实用程序创建的备份文件基本上是一组可用于重新创建原始数据库的 SQL 语句。mysqldump 命令还可以生成 CSV 和 XML 格式的文件。您还可以使用mysql转储实用程序将MySQL数据库传输到另一个MySQL服务器。如果不备份数据库,软件错误或硬盘驱动器故障可能是灾难性的。为了帮助您节省大量时间和挫折感,强烈建议您采取预防措施,定期备份MySQL数据库。M_mysqldump --database