安装Scala
https://www.runoob.com/scala/scala-install.html
有个坑,scala这个语言的兼容性极差。
一定要和对应的spark版本兼容,不然就会报错!
这里我用的是2.12版本的scala
spark版本为最新的
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.4</version>
</dependency>
</dependencies>
新建项目
https://blog.csdn.net/u012834750/article/details/81014997
maven依赖如上,如果用windows而且不是HDFS环境就不要导入下面这个
<!--<dependency>-->
<!--<groupId>org.apache.hadoop</groupId>-->
<!--<artifactId>hadoop-client</artifactId>-->
<!--<version>2.6.0</version>-->
<!--</dependency>-->
这在spark的官网有写
https://spark.apache.org/docs/latest/rdd-programming-guide.html
hadoop.ddl
写完代码以后直接跑,会报错
java.io.IOException: (null) entry in command string: null chmod 0644 C:UsersadminDesktop大数据分析ass1
esult
解决方法:
下载hadoop.dll文件,拷贝到c:windowssystem32目录中即可
hadoop.dll可以在github上下载:https://github.com/4ttty/winutils
各个版本的hadoop.dll好像是通用的。
百度网盘
链接:https://pan.baidu.com/s/12-MMoz0LYSbEYl_GMiwb3A
提取码:rkxq