第一步,引入依赖
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.4.0-cdh6.3.0</version>
<!--<scope>provided</scope>-->
</dependency>
<repositories>
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
</repositories>
第二步创建SparkContext
val sparkConfig: SparkConf = new SparkConf().setMaster("local").setAppName("随便写个名字")
//Spark上下文
val sparkContext = new SparkContext(sparkConfig)
第三步写代码
hbaseRdd.foreach(rdd => {
val record: Result = rdd._2
})
网友评论