Springboot(2.0.0.RELEASE)+spark(2.1.0)框架整合到jar包成功发布(原创)!!!

一、前言

  首先说明一下,这个框架的整合可能对大神来说十分容易,但是对我来说十分不易,踩了不少坑。虽然整合的时间不长,但是值得来纪念下!!!我个人开发工具比较喜欢IDEA,创建的springboot的java工程再引入scala的library之后当前工程即可创建java文件又可创建scala文件,这个一个工程里可采用java+scala双语言来开发。用了这个框架搭建成功后给我们开发spark代码能带来什么便利之处?

  1、springboot可以开发非web项目,与spark不相关的代码可以采用java来开发,比如访问数据库,中间件等,用java十分便利。

  2、spark相关开发采用scala语言代码量更少,开发效率更高。

  主要基于以上两点,搭建这个框架还是具有不小的意义。

二、搭建过程

  1、利用maven引入springboot的基础jar包

  2、利用maven引入spark相关jar包

  3、利用maven引入解决冲突的jar包

完整pom文件如下:
<?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>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>

<groupId>ba</groupId>
<artifactId>SparkTest01</artifactId>
<version>1.0-SNAPSHOT</version>

<name>SparkTest01</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<spark.version>2.1.0</spark.version>
<hadoop.version>2.7.4</hadoop.version>
<springboot.version>2.0.0.RELEASE</springboot.version>
</properties>
<dependencies>
<!--spark框架开始-->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>${spark.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hive_2.11</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.11</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${hadoop.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--spark框架结束-->

<!--springboot开始 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${springboot.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<version>${springboot.version}</version>
</dependency>
<!-- springboot框架结束-->

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<!--解决框架加载失败 -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<!--解决框架加载失败 -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.4.Final</version>
</dependency>

</dependencies>

<build>
<plugins>
<!-- springboot maven打包-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

注意:1、黄色标记是作用是jar包冲突。
   2、青色标记是解决框架引入失败的问题。
    
三、实测结果
  

 

 

 

 

 

四、打jar包发布至spark平台
 坑:将spark安装包里的gson-2.2.4.jar从jars目录移除!!!
 打包打用的spring-boot-maven-plugin插件,将jar放至spark服务器上,提交代码时指定类为springboot的启动代理类--class org.springframework.boot.loader.JarLauncher。以下是提交命令:
 spark-submit --class org.springframework.boot.loader.JarLauncher SparkStudy01-1.0-SNAPSHOT.jar

以下是运行的结果:

 






转载于:https://www.cnblogs.com/runnerjack/p/9446660.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/389962.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

求一个张量的梯度_张量流中离散策略梯度的最小工作示例2 0

求一个张量的梯度Training discrete actor networks with TensorFlow 2.0 is easy once you know how to do it, but also rather different from implementations in TensorFlow 1.0. As the 2.0 version was only released in September 2019, most examples that circulate …

zabbix网络发现主机

1 功能介绍 默认情况下&#xff0c;当我在主机上安装agent&#xff0c;然后要在server上手动添加主机并连接到模板&#xff0c;加入一个主机组。 如果有很多主机&#xff0c;并且经常变动&#xff0c;手动操作就很麻烦。 网络发现就是主机上安装了agent&#xff0c;然后server自…

python股市_如何使用python和破折号创建仪表板来主导股市

python股市始终关注大局 (Keep Your Eyes on the Big Picture) I’ve been fascinated with the stock market since I was a little kid. There is certainly no shortage of data to analyze, and if you find an edge you can make some easy money. To stay on top of the …

阿里巴巴开源 Sentinel,进一步完善 Dubbo 生态

为什么80%的码农都做不了架构师&#xff1f;>>> 阿里巴巴开源 Sentinel&#xff0c;进一步完善 Dubbo 生态 Sentinel 开源地址&#xff1a;https://github.com/alibaba/Sentinel 转载于:https://my.oschina.net/dyyweb/blog/1925839

离群值如何处理_有理处理离群值的局限性

离群值如何处理ARIMA models can be quite adept when it comes to modelling the overall trend of a series along with seasonal patterns.ARIMA模型可以很好地建模一系列总体趋势以及季节性模式。 In a previous article titled SARIMA: Forecasting Seasonal Data with P…

10生活便捷:购物、美食、看病时这样搜,至少能省一半心

本次课程介绍实实在在能够救命、省钱的网站&#xff0c;解决了眼前这些需求后&#xff0c;还有“诗和远方”——不花钱也能点亮自己的生活&#xff0c;获得美的享受&#xff01; 1、健康医疗这么搜&#xff0c;安全又便捷 现在的医疗市场确实有些混乱&#xff0c;由于医疗的专业…

ppt图表图表类型起始_梅科图表

ppt图表图表类型起始There are different types of variable width bar charts but two are the most popular: 1) Bar Mekko chart; 2) Marimekko chart.可变宽度条形图有不同类型&#xff0c;但最受欢迎的有两种&#xff1a;1)Mekko条形图&#xff1b; 2)Marimekko图表。 Th…

Tomcat日志乱码了怎么处理?

【前言】 tomacat日志有三个地方&#xff0c;分别是Output(控制台)、Tomcat Localhost Log(tomcat本地日志)、Tomcat Catalina Log。 启动日志和大部分报错日志、普通日志都在output打印;有些错误日志&#xff0c;在Tomcat Localhost Log。 三个日志显示区&#xff0c;都可能…

5888. 网络空闲的时刻

5888. 网络空闲的时刻 给你一个有 n 个服务器的计算机网络&#xff0c;服务器编号为 0 到 n - 1 。同时给你一个二维整数数组 edges &#xff0c;其中 edges[i] [ui, vi] 表示服务器 ui 和 vi 之间有一条信息线路&#xff0c;在 一秒 内它们之间可以传输 任意 数目的信息。再…

django框架预备知识

内容&#xff1a; 1.web预备知识 2.django介绍 3.web框架的本质及分类 4.django安装与基本设置 1.web预备知识 HTTP协议&#xff1a;https://www.cnblogs.com/wyb666/p/9383077.html 关于web的本质&#xff1a;http://www.cnblogs.com/wyb666/p/9034042.html 如何自定义web框架…

现实世界 机器学习_公司沟通分析简介现实世界的机器学习方法

现实世界 机器学习In my previous posts I covered analytical subjects from a scientific point of view, rather than an applied real world problem. For this reason, this article aims at approaching an analytical idea from a managerial point of view, rather tha…

拷贝构造函数和赋值函数

1、拷贝构造函数&#xff1a;用一个已经有的对象构造一个新的对象。 CA&#xff08;const CA & c &#xff09;函数的名称必须和类名称相一致&#xff0c;它的唯一的一个参数是本类型的一个引用变量&#xff0c;该参数是const 类型&#xff0c;不可变。 拷贝构造函数什么时…

Chrome keyboard shortcuts

2019独角兽企业重金招聘Python工程师标准>>> Chrome keyboard shortcuts https://support.google.com/chrome/answer/157179?hlen 转载于:https://my.oschina.net/qwfys200/blog/1927456

数据中心细节_当细节很重要时数据不平衡

数据中心细节定义不平衡数据 (Definition Imbalanced Data) When we speak of imbalanced data, what we mean is that at least one class is underrepresented. For example, when considering the problem of building a classifier, let’s call it the Idealisstic-Voter.…

辛普森悖论_所谓的辛普森悖论

辛普森悖论We all know the Simpsons family from Disneyland, but have you heard about the Simpson’s Paradox from statistic theory? This article will illustrate the definition of Simpson’s Paradox with an example, and show you how can it harm your statisti…

查看NVIDIA使用率工具目录

2019独角兽企业重金招聘Python工程师标准>>> C:\Program Files\NVIDIA Corporation\Display.NvContainer\NVDisplay.Container.exe 转载于:https://my.oschina.net/u/2430809/blog/1927560

余弦相似度和欧氏距离_欧氏距离和余弦相似度

余弦相似度和欧氏距离Photo by Markus Winkler on UnsplashMarkus Winkler在Unsplash上拍摄的照片 This is a quick and straight to the point introduction to Euclidean distance and cosine similarity with a focus on NLP.这是对欧氏距离和余弦相似度的快速而直接的介绍&…

七、 面向对象(二)

匿名类对象 创建的类的对象是匿名的。当我们只需要一次调用类的对象时&#xff0c;我们就可以考虑使用匿名的方式创建类的对象。特点是创建的匿名类的对象只能够调用一次&#xff01; package day007;//圆的面积 class circle {double radius;public double getArea() {// TODO…

机器学习 客户流失_通过机器学习预测流失

机器学习 客户流失介绍 (Introduction) This article is part of a project for Udacity “Become a Data Scientist Nano Degree”. The Jupyter Notebook with the code for this project can be downloaded from GitHub.本文是Udacity“成为数据科学家纳米学位”项目的一部分…

Qt中的坐标系统

转载&#xff1a;原野追逐 Qt使用统一的坐标系统来定位窗口部件的位置和大小。 以屏幕的左上角为原点即(0, 0)点&#xff0c;从左向右为x轴正向&#xff0c;从上向下为y轴正向&#xff0c;这整个屏幕的坐标系统就用来定位顶层窗口&#xff1b; 此外&#xff0c;窗口内部也有自己…