标签:color 内容 依赖 oid style dep ext override end
1.首先引入依赖
<dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-core_2.11</artifactId> <version>2.0.0</version> </dependency>
2.在项目根路径创建aa.txt文件,内容随意
3.编写hello wordCount示例
public static void main( String[] args ){
//配置信息 SparkConf conf = new SparkConf()
.setAppName("JavaWordCount")
//设置本地运行
.setMaster("local"); JavaSparkContext sc = new JavaSparkContext(conf);
//获取元素列表 JavaRDD<String> lineRDD = sc.textFile("./aa.txt");
//遍历 lineRDD.foreach(new VoidFunction<String>() { private static final long serialVersionUID = 1L; @Override public void call(String s) throws Exception { System.out.println( "Hello World!"+s ); } }); }
标签:color 内容 依赖 oid style dep ext override end
原文地址:https://www.cnblogs.com/wannt/p/10594263.html