• 基于IDEA环境下的Spark2.X程序开发


     

    我们选择在线安装

    这个是windows下的scala,直接双击安装就可以了

    安装好之后可以验证一下

     

    这个是我本地的jdk1.8安装包,直接双击安装

    安装完成后可以验证一下

    https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/

     

    解压

     

     我的本地是win10系统

     

    配置好环境变量我们可以验证一下

    修改这个文件

    这个是默认的

    改成这样子

    把本地的maven配置进来

     

     

    接下来就是等待自动把相应的架包下载下来

     

     

    把scala添加进来了

     接下来我们创建目录

     

     

    在scala目录下建包

     

     在这个包里面创建一个scala的类

    输入以下代码

    配置maven的 pom.xml文件

    <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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.spark</groupId>
    <artifactId>sparkStu</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>sparkStu Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
    <hadoop.version>2.6.0</hadoop.version>
    <scala.binary.version>2.11</scala.binary.version>
    <spark.version>2.2.0</spark.version>
    </properties>

    <dependencies>
    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-core_${scala.binary.version}</artifactId>
    <version>${spark.version}</version>
    </dependency>

    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-sql_${scala.binary.version}</artifactId>
    <version>${spark.version}</version>
    </dependency>

    <!--
    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-core_2.11</artifactId>
    <version>2.2.0</version>
    </dependency>
    -->
    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-streaming_${scala.binary.version}</artifactId>
    <version>${spark.version}</version>
    </dependency>

    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-hive_${scala.binary.version}</artifactId>
    <version>${spark.version}</version>
    </dependency>

    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-streaming-kafka-0-10_${scala.binary.version}</artifactId>
    <version>${spark.version}</version>
    </dependency>

    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-sql-kafka-0-10_${scala.binary.version}</artifactId>
    <version>${spark.version}</version>
    </dependency>

    <dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-client</artifactId>
    <version>${hadoop.version}</version>
    </dependency>

    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>



    </dependencies>
    <build>
    <finalName>sparkStu</finalName>
    </build>
    </project>

     在Test.scala里加上这段内容

     我们编写一个简单的代码

    package com.spark.test
    
    import org.apache.spark.sql.SparkSession
    
    object Test {
    
      def main(args: Array[String]): Unit = {
       val spark= SparkSession
           .builder
             .appName("HdfsTest")
               .getOrCreate()
         val filePart = "E://Mycode/datas/stu.txt"
         val rdd= spark.sparkContext.textFile(filePart)
    
         val lines= rdd.flatMap(x => x.split(" ")).collect().toList
         println(lines)
      }
    }

     运行一下

     结果报错了

    E:softwarejdk1.8injava "-javaagent:E:softwareIDEAIntelliJ IDEA 2017.2.6libidea_rt.jar=59010:E:softwareIDEAIntelliJ IDEA 2017.2.6in" -Dfile.encoding=UTF-8 -classpath E:softwarejdk1.8jrelibcharsets.jar;E:softwarejdk1.8jrelibdeploy.jar;E:softwarejdk1.8jrelibextaccess-bridge-64.jar;E:softwarejdk1.8jrelibextcldrdata.jar;E:softwarejdk1.8jrelibextdnsns.jar;E:softwarejdk1.8jrelibextjaccess.jar;E:softwarejdk1.8jrelibextjfxrt.jar;E:softwarejdk1.8jrelibextlocaledata.jar;E:softwarejdk1.8jrelibext
    ashorn.jar;E:softwarejdk1.8jrelibextsunec.jar;E:softwarejdk1.8jrelibextsunjce_provider.jar;E:softwarejdk1.8jrelibextsunmscapi.jar;E:softwarejdk1.8jrelibextsunpkcs11.jar;E:softwarejdk1.8jrelibextzipfs.jar;E:softwarejdk1.8jrelibjavaws.jar;E:softwarejdk1.8jrelibjce.jar;E:softwarejdk1.8jrelibjfr.jar;E:softwarejdk1.8jrelibjfxswt.jar;E:softwarejdk1.8jrelibjsse.jar;E:softwarejdk1.8jrelibmanagement-agent.jar;E:softwarejdk1.8jrelibplugin.jar;E:softwarejdk1.8jrelib
    esources.jar;E:softwarejdk1.8jrelib
    t.jar;E:MycodeSparkStu	argetclasses;E:softwareScalalibscala-actors-2.11.0.jar;E:softwareScalalibscala-actors-migration_2.11-1.1.0.jar;E:softwareScalalibscala-library.jar;E:softwareScalalibscala-parser-combinators_2.11-1.0.4.jar;E:softwareScalalibscala-reflect.jar;E:softwareScalalibscala-swing_2.11-1.0.2.jar;E:softwareScalalibscala-xml_2.11-1.0.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-core_2.112.2.0spark-core_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro1.7.7avro-1.7.7.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-core-asl1.9.13jackson-core-asl-1.9.13.jar;E:softwaremaven3.3.9
    epositorycom	houghtworksparanamerparanamer2.3paranamer-2.3.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-compress1.4.1commons-compress-1.4.1.jar;E:softwaremaven3.3.9
    epositoryorg	ukaanixz1.0xz-1.0.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro-mapred1.7.7avro-mapred-1.7.7-hadoop2.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro-ipc1.7.7avro-ipc-1.7.7.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro-ipc1.7.7avro-ipc-1.7.7-tests.jar;E:softwaremaven3.3.9
    epositorycom	witterchill_2.110.8.0chill_2.11-0.8.0.jar;E:softwaremaven3.3.9
    epositorycomesotericsoftwarekryo-shaded3.0.3kryo-shaded-3.0.3.jar;E:softwaremaven3.3.9
    epositorycomesotericsoftwareminlog1.3.0minlog-1.3.0.jar;E:softwaremaven3.3.9
    epositoryorgobjenesisobjenesis2.1objenesis-2.1.jar;E:softwaremaven3.3.9
    epositorycom	witterchill-java0.8.0chill-java-0.8.0.jar;E:softwaremaven3.3.9
    epositoryorgapachexbeanxbean-asm5-shaded4.4xbean-asm5-shaded-4.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-launcher_2.112.2.0spark-launcher_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-network-common_2.112.2.0spark-network-common_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgfusesourceleveldbjnileveldbjni-all1.8leveldbjni-all-1.8.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksoncorejackson-annotations2.6.5jackson-annotations-2.6.5.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-network-shuffle_2.112.2.0spark-network-shuffle_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-unsafe_2.112.2.0spark-unsafe_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epository
    etjavadevjets3tjets3t0.9.3jets3t-0.9.3.jar;E:softwaremaven3.3.9
    epositoryorgapachehttpcomponentshttpcore4.3.3httpcore-4.3.3.jar;E:softwaremaven3.3.9
    epositoryjavaxactivationactivation1.1.1activation-1.1.1.jar;E:softwaremaven3.3.9
    epositorymx4jmx4j3.0.2mx4j-3.0.2.jar;E:softwaremaven3.3.9
    epositoryjavaxmailmail1.4.7mail-1.4.7.jar;E:softwaremaven3.3.9
    epositoryorgouncycastlecprov-jdk15on1.51cprov-jdk15on-1.51.jar;E:softwaremaven3.3.9
    epositorycomjamesmurtyutilsjava-xmlbuilder1.0java-xmlbuilder-1.0.jar;E:softwaremaven3.3.9
    epository
    etiharderase642.3.8ase64-2.3.8.jar;E:softwaremaven3.3.9
    epositoryorgapachecuratorcurator-recipes2.6.0curator-recipes-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachecuratorcurator-framework2.6.0curator-framework-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachezookeeperzookeeper3.4.6zookeeper-3.4.6.jar;E:softwaremaven3.3.9
    epositorycomgoogleguavaguava16.0.1guava-16.0.1.jar;E:softwaremaven3.3.9
    epositoryjavaxservletjavax.servlet-api3.1.0javax.servlet-api-3.1.0.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-lang33.5commons-lang3-3.5.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-math33.4.1commons-math3-3.4.1.jar;E:softwaremaven3.3.9
    epositorycomgooglecodefindbugsjsr3051.3.9jsr305-1.3.9.jar;E:softwaremaven3.3.9
    epositoryorgslf4jslf4j-api1.7.16slf4j-api-1.7.16.jar;E:softwaremaven3.3.9
    epositoryorgslf4jjul-to-slf4j1.7.16jul-to-slf4j-1.7.16.jar;E:softwaremaven3.3.9
    epositoryorgslf4jjcl-over-slf4j1.7.16jcl-over-slf4j-1.7.16.jar;E:softwaremaven3.3.9
    epositorylog4jlog4j1.2.17log4j-1.2.17.jar;E:softwaremaven3.3.9
    epositoryorgslf4jslf4j-log4j121.7.16slf4j-log4j12-1.7.16.jar;E:softwaremaven3.3.9
    epositorycom
    ingcompress-lzf1.0.3compress-lzf-1.0.3.jar;E:softwaremaven3.3.9
    epositoryorgxerialsnappysnappy-java1.1.2.6snappy-java-1.1.2.6.jar;E:softwaremaven3.3.9
    epository
    etjpountzlz4lz41.3.0lz4-1.3.0.jar;E:softwaremaven3.3.9
    epositoryorg
    oaringbitmapRoaringBitmap0.5.11RoaringBitmap-0.5.11.jar;E:softwaremaven3.3.9
    epositorycommons-netcommons-net2.2commons-net-2.2.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscala-library2.11.8scala-library-2.11.8.jar;E:softwaremaven3.3.9
    epositoryorgjson4sjson4s-jackson_2.113.2.11json4s-jackson_2.11-3.2.11.jar;E:softwaremaven3.3.9
    epositoryorgjson4sjson4s-core_2.113.2.11json4s-core_2.11-3.2.11.jar;E:softwaremaven3.3.9
    epositoryorgjson4sjson4s-ast_2.113.2.11json4s-ast_2.11-3.2.11.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscalap2.11.0scalap-2.11.0.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscala-compiler2.11.0scala-compiler-2.11.0.jar;E:softwaremaven3.3.9
    epositoryorgscala-langmodulesscala-xml_2.111.0.1scala-xml_2.11-1.0.1.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycorejersey-client2.22.2jersey-client-2.22.2.jar;E:softwaremaven3.3.9
    epositoryjavaxws
    sjavax.ws.rs-api2.0.1javax.ws.rs-api-2.0.1.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2hk2-api2.4.0-b34hk2-api-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2hk2-utils2.4.0-b34hk2-utils-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2externalaopalliance-repackaged2.4.0-b34aopalliance-repackaged-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2externaljavax.inject2.4.0-b34javax.inject-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2hk2-locator2.4.0-b34hk2-locator-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgjavassistjavassist3.18.1-GAjavassist-3.18.1-GA.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycorejersey-common2.22.2jersey-common-2.22.2.jar;E:softwaremaven3.3.9
    epositoryjavaxannotationjavax.annotation-api1.2javax.annotation-api-1.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseyundles
    epackagedjersey-guava2.22.2jersey-guava-2.22.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2osgi-resource-locator1.0.1osgi-resource-locator-1.0.1.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycorejersey-server2.22.2jersey-server-2.22.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseymediajersey-media-jaxb2.22.2jersey-media-jaxb-2.22.2.jar;E:softwaremaven3.3.9
    epositoryjavaxvalidationvalidation-api1.1.0.Finalvalidation-api-1.1.0.Final.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycontainersjersey-container-servlet2.22.2jersey-container-servlet-2.22.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycontainersjersey-container-servlet-core2.22.2jersey-container-servlet-core-2.22.2.jar;E:softwaremaven3.3.9
    epositoryio
    etty
    etty-all4.0.43.Final
    etty-all-4.0.43.Final.jar;E:softwaremaven3.3.9
    epositoryio
    etty
    etty3.9.9.Final
    etty-3.9.9.Final.jar;E:softwaremaven3.3.9
    epositorycomclearspringanalyticsstream2.7.0stream-2.7.0.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-core3.1.2metrics-core-3.1.2.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-jvm3.1.2metrics-jvm-3.1.2.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-json3.1.2metrics-json-3.1.2.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-graphite3.1.2metrics-graphite-3.1.2.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksoncorejackson-databind2.6.5jackson-databind-2.6.5.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksoncorejackson-core2.6.5jackson-core-2.6.5.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksonmodulejackson-module-scala_2.112.6.5jackson-module-scala_2.11-2.6.5.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscala-reflect2.11.7scala-reflect-2.11.7.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksonmodulejackson-module-paranamer2.6.5jackson-module-paranamer-2.6.5.jar;E:softwaremaven3.3.9
    epositoryorgapacheivyivy2.4.0ivy-2.4.0.jar;E:softwaremaven3.3.9
    epositoryorooro2.0.8oro-2.0.8.jar;E:softwaremaven3.3.9
    epository
    et
    azorvinepyrolite4.13pyrolite-4.13.jar;E:softwaremaven3.3.9
    epository
    etsfpy4jpy4j0.10.4py4j-0.10.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-tags_2.112.2.0spark-tags_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-crypto1.0.0commons-crypto-1.0.0.jar;E:softwaremaven3.3.9
    epositoryorgspark-projectsparkunused1.0.0unused-1.0.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-sql_2.112.2.0spark-sql_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositorycomunivocityunivocity-parsers2.2.1univocity-parsers-2.2.1.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-sketch_2.112.2.0spark-sketch_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-catalyst_2.112.2.0spark-catalyst_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjaninojanino3.0.0janino-3.0.0.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjaninocommons-compiler3.0.0commons-compiler-3.0.0.jar;E:softwaremaven3.3.9
    epositoryorgantlrantlr4-runtime4.5.3antlr4-runtime-4.5.3.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-column1.8.2parquet-column-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-common1.8.2parquet-common-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-encoding1.8.2parquet-encoding-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-hadoop1.8.2parquet-hadoop-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-format2.3.1parquet-format-2.3.1.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-jackson1.8.2parquet-jackson-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-streaming_2.112.2.0spark-streaming_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-hive_2.112.2.0spark-hive_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositorycom	witterparquet-hadoop-bundle1.6.0parquet-hadoop-bundle-1.6.0.jar;E:softwaremaven3.3.9
    epositoryorgspark-projecthivehive-exec1.2.1.spark2hive-exec-1.2.1.spark2.jar;E:softwaremaven3.3.9
    epositorycommons-iocommons-io2.4commons-io-2.4.jar;E:softwaremaven3.3.9
    epositorycommons-langcommons-lang2.6commons-lang-2.6.jar;E:softwaremaven3.3.9
    epositoryjavolutionjavolution5.5.1javolution-5.5.1.jar;E:softwaremaven3.3.9
    epositorylog4japache-log4j-extras1.2.17apache-log4j-extras-1.2.17.jar;E:softwaremaven3.3.9
    epositoryorgantlrantlr-runtime3.4antlr-runtime-3.4.jar;E:softwaremaven3.3.9
    epositoryorgantlrstringtemplate3.2.1stringtemplate-3.2.1.jar;E:softwaremaven3.3.9
    epositoryantlrantlr2.7.7antlr-2.7.7.jar;E:softwaremaven3.3.9
    epositoryorgantlrST44.0.4ST4-4.0.4.jar;E:softwaremaven3.3.9
    epositorycomgooglecodejavaewahJavaEWAH0.3.2JavaEWAH-0.3.2.jar;E:softwaremaven3.3.9
    epositoryorgiq80snappysnappy0.2snappy-0.2.jar;E:softwaremaven3.3.9
    epositorystaxstax-api1.0.1stax-api-1.0.1.jar;E:softwaremaven3.3.9
    epository
    etsfopencsvopencsv2.3opencsv-2.3.jar;E:softwaremaven3.3.9
    epositoryorgspark-projecthivehive-metastore1.2.1.spark2hive-metastore-1.2.1.spark2.jar;E:softwaremaven3.3.9
    epositorycomjolboxonecp0.8.0.RELEASEonecp-0.8.0.RELEASE.jar;E:softwaremaven3.3.9
    epositorycommons-clicommons-cli1.2commons-cli-1.2.jar;E:softwaremaven3.3.9
    epositorycommons-loggingcommons-logging1.1.3commons-logging-1.1.3.jar;E:softwaremaven3.3.9
    epositoryorgapachederbyderby10.10.2.0derby-10.10.2.0.jar;E:softwaremaven3.3.9
    epositoryorgdatanucleusdatanucleus-api-jdo3.2.6datanucleus-api-jdo-3.2.6.jar;E:softwaremaven3.3.9
    epositoryorgdatanucleusdatanucleus-rdbms3.2.9datanucleus-rdbms-3.2.9.jar;E:softwaremaven3.3.9
    epositorycommons-poolcommons-pool1.5.4commons-pool-1.5.4.jar;E:softwaremaven3.3.9
    epositorycommons-dbcpcommons-dbcp1.4commons-dbcp-1.4.jar;E:softwaremaven3.3.9
    epositoryjavaxjdojdo-api3.0.1jdo-api-3.0.1.jar;E:softwaremaven3.3.9
    epositoryjavax	ransactionjta1.1jta-1.1.jar;E:softwaremaven3.3.9
    epositorycommons-httpclientcommons-httpclient3.1commons-httpclient-3.1.jar;E:softwaremaven3.3.9
    epositoryorgapachecalcitecalcite-avatica1.2.0-incubatingcalcite-avatica-1.2.0-incubating.jar;E:softwaremaven3.3.9
    epositoryorgapachecalcitecalcite-core1.2.0-incubatingcalcite-core-1.2.0-incubating.jar;E:softwaremaven3.3.9
    epositoryorgapachecalcitecalcite-linq4j1.2.0-incubatingcalcite-linq4j-1.2.0-incubating.jar;E:softwaremaven3.3.9
    epository
    ethydromaticeigenbase-properties1.1.5eigenbase-properties-1.1.5.jar;E:softwaremaven3.3.9
    epositoryorgapachehttpcomponentshttpclient4.5.2httpclient-4.5.2.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-mapper-asl1.9.13jackson-mapper-asl-1.9.13.jar;E:softwaremaven3.3.9
    epositorycommons-codeccommons-codec1.10commons-codec-1.10.jar;E:softwaremaven3.3.9
    epositoryjoda-timejoda-time2.9.3joda-time-2.9.3.jar;E:softwaremaven3.3.9
    epositoryorgjoddjodd-core3.5.2jodd-core-3.5.2.jar;E:softwaremaven3.3.9
    epositoryorgdatanucleusdatanucleus-core3.2.10datanucleus-core-3.2.10.jar;E:softwaremaven3.3.9
    epositoryorgapache	hriftlibthrift0.9.3libthrift-0.9.3.jar;E:softwaremaven3.3.9
    epositoryorgapache	hriftlibfb3030.9.3libfb303-0.9.3.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-streaming-kafka-0-10_2.112.2.0spark-streaming-kafka-0-10_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachekafkakafka_2.110.10.0.1kafka_2.11-0.10.0.1.jar;E:softwaremaven3.3.9
    epositorycom101teczkclient0.8zkclient-0.8.jar;E:softwaremaven3.3.9
    epositorycomyammermetricsmetrics-core2.2.0metrics-core-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgscala-langmodulesscala-parser-combinators_2.111.0.4scala-parser-combinators_2.11-1.0.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-sql-kafka-0-10_2.112.2.0spark-sql-kafka-0-10_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachekafkakafka-clients0.10.0.1kafka-clients-0.10.0.1.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-client2.6.0hadoop-client-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-common2.6.0hadoop-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryxmlencxmlenc0.52xmlenc-0.52.jar;E:softwaremaven3.3.9
    epositorycommons-collectionscommons-collections3.2.1commons-collections-3.2.1.jar;E:softwaremaven3.3.9
    epositorycommons-configurationcommons-configuration1.6commons-configuration-1.6.jar;E:softwaremaven3.3.9
    epositorycommons-digestercommons-digester1.8commons-digester-1.8.jar;E:softwaremaven3.3.9
    epositorycommons-beanutilscommons-beanutils1.7.0commons-beanutils-1.7.0.jar;E:softwaremaven3.3.9
    epositorycommons-beanutilscommons-beanutils-core1.8.0commons-beanutils-core-1.8.0.jar;E:softwaremaven3.3.9
    epositorycomgoogleprotobufprotobuf-java2.5.0protobuf-java-2.5.0.jar;E:softwaremaven3.3.9
    epositorycomgooglecodegsongson2.2.4gson-2.2.4.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-auth2.6.0hadoop-auth-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryserverapacheds-kerberos-codec2.0.0-M15apacheds-kerberos-codec-2.0.0-M15.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryserverapacheds-i18n2.0.0-M15apacheds-i18n-2.0.0-M15.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryapiapi-asn1-api1.0.0-M20api-asn1-api-1.0.0-M20.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryapiapi-util1.0.0-M20api-util-1.0.0-M20.jar;E:softwaremaven3.3.9
    epositoryorgapachecuratorcurator-client2.6.0curator-client-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorghtracehtrace-core3.0.4htrace-core-3.0.4.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-hdfs2.6.0hadoop-hdfs-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgmortbayjettyjetty-util6.1.26jetty-util-6.1.26.jar;E:softwaremaven3.3.9
    epositoryxercesxercesImpl2.9.1xercesImpl-2.9.1.jar;E:softwaremaven3.3.9
    epositoryxml-apisxml-apis1.3.04xml-apis-1.3.04.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-app2.6.0hadoop-mapreduce-client-app-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-common2.6.0hadoop-mapreduce-client-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-client2.6.0hadoop-yarn-client-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-server-common2.6.0hadoop-yarn-server-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-shuffle2.6.0hadoop-mapreduce-client-shuffle-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-api2.6.0hadoop-yarn-api-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-core2.6.0hadoop-mapreduce-client-core-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-common2.6.0hadoop-yarn-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryjavaxxmlindjaxb-api2.2.2jaxb-api-2.2.2.jar;E:softwaremaven3.3.9
    epositoryjavaxxmlstreamstax-api1.0-2stax-api-1.0-2.jar;E:softwaremaven3.3.9
    epositoryjavaxservletservlet-api2.5servlet-api-2.5.jar;E:softwaremaven3.3.9
    epositorycomsunjerseyjersey-core1.9jersey-core-1.9.jar;E:softwaremaven3.3.9
    epositorycomsunjerseyjersey-client1.9jersey-client-1.9.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-jaxrs1.9.13jackson-jaxrs-1.9.13.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-xc1.9.13jackson-xc-1.9.13.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-jobclient2.6.0hadoop-mapreduce-client-jobclient-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-annotations2.6.0hadoop-annotations-2.6.0.jar com.spark.test.Test
    Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
    18/03/14 17:01:07 INFO SparkContext: Running Spark version 2.2.0
    18/03/14 17:01:07 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    18/03/14 17:01:08 ERROR Shell: Failed to locate the winutils binary in the hadoop binary path
    java.io.IOException: Could not locate executable nullinwinutils.exe in the Hadoop binaries.
        at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:355)
        at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:370)
        at org.apache.hadoop.util.Shell.<clinit>(Shell.java:363)
        at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:79)
        at org.apache.hadoop.security.Groups.parseStaticMapping(Groups.java:104)
        at org.apache.hadoop.security.Groups.<init>(Groups.java:86)
        at org.apache.hadoop.security.Groups.<init>(Groups.java:66)
        at org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:280)
        at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:271)
        at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:248)
        at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:763)
        at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:748)
        at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:621)
        at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2430)
        at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2430)
        at scala.Option.getOrElse(Option.scala:121)
        at org.apache.spark.util.Utils$.getCurrentUserName(Utils.scala:2430)
        at org.apache.spark.SparkContext.<init>(SparkContext.scala:295)
        at org.apache.spark.SparkContext$.getOrCreate(SparkContext.scala:2509)
        at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:909)
        at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:901)
        at scala.Option.getOrElse(Option.scala:121)
        at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:901)
        at com.spark.test.Test$.main(Test.scala:11)
        at com.spark.test.Test.main(Test.scala)
    18/03/14 17:01:08 ERROR SparkContext: Error initializing SparkContext.
    org.apache.spark.SparkException: A master URL must be set in your configuration
        at org.apache.spark.SparkContext.<init>(SparkContext.scala:376)
        at org.apache.spark.SparkContext$.getOrCreate(SparkContext.scala:2509)
        at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:909)
        at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:901)
        at scala.Option.getOrElse(Option.scala:121)
        at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:901)
        at com.spark.test.Test$.main(Test.scala:11)
        at com.spark.test.Test.main(Test.scala)
    18/03/14 17:01:08 INFO SparkContext: Successfully stopped SparkContext
    Exception in thread "main" org.apache.spark.SparkException: A master URL must be set in your configuration
        at org.apache.spark.SparkContext.<init>(SparkContext.scala:376)
        at org.apache.spark.SparkContext$.getOrCreate(SparkContext.scala:2509)
        at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:909)
        at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:901)
        at scala.Option.getOrElse(Option.scala:121)
        at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:901)
        at com.spark.test.Test$.main(Test.scala:11)
        at com.spark.test.Test.main(Test.scala)
    
    Process finished with exit code 1

     这是因为我本地没有配置好hadoop,现在我们配一个

    这个是我本地的hadoop/bin

     下面把本地win10的环境变量配置一下

     

     

     再重启一下idea,再运行一下程序

    报了另外一个错误,但是可以确定的是前面的错误我们解决了

    E:softwarejdk1.8injava "-javaagent:E:softwareIDEAIntelliJ IDEA 2017.2.6libidea_rt.jar=60011:E:softwareIDEAIntelliJ IDEA 2017.2.6in" -Dfile.encoding=UTF-8 -classpath E:softwarejdk1.8jrelibcharsets.jar;E:softwarejdk1.8jrelibdeploy.jar;E:softwarejdk1.8jrelibextaccess-bridge-64.jar;E:softwarejdk1.8jrelibextcldrdata.jar;E:softwarejdk1.8jrelibextdnsns.jar;E:softwarejdk1.8jrelibextjaccess.jar;E:softwarejdk1.8jrelibextjfxrt.jar;E:softwarejdk1.8jrelibextlocaledata.jar;E:softwarejdk1.8jrelibext
    ashorn.jar;E:softwarejdk1.8jrelibextsunec.jar;E:softwarejdk1.8jrelibextsunjce_provider.jar;E:softwarejdk1.8jrelibextsunmscapi.jar;E:softwarejdk1.8jrelibextsunpkcs11.jar;E:softwarejdk1.8jrelibextzipfs.jar;E:softwarejdk1.8jrelibjavaws.jar;E:softwarejdk1.8jrelibjce.jar;E:softwarejdk1.8jrelibjfr.jar;E:softwarejdk1.8jrelibjfxswt.jar;E:softwarejdk1.8jrelibjsse.jar;E:softwarejdk1.8jrelibmanagement-agent.jar;E:softwarejdk1.8jrelibplugin.jar;E:softwarejdk1.8jrelib
    esources.jar;E:softwarejdk1.8jrelib
    t.jar;E:MycodeSparkStu	argetclasses;E:softwareScalalibscala-actors-2.11.0.jar;E:softwareScalalibscala-actors-migration_2.11-1.1.0.jar;E:softwareScalalibscala-library.jar;E:softwareScalalibscala-parser-combinators_2.11-1.0.4.jar;E:softwareScalalibscala-reflect.jar;E:softwareScalalibscala-swing_2.11-1.0.2.jar;E:softwareScalalibscala-xml_2.11-1.0.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-core_2.112.2.0spark-core_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro1.7.7avro-1.7.7.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-core-asl1.9.13jackson-core-asl-1.9.13.jar;E:softwaremaven3.3.9
    epositorycom	houghtworksparanamerparanamer2.3paranamer-2.3.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-compress1.4.1commons-compress-1.4.1.jar;E:softwaremaven3.3.9
    epositoryorg	ukaanixz1.0xz-1.0.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro-mapred1.7.7avro-mapred-1.7.7-hadoop2.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro-ipc1.7.7avro-ipc-1.7.7.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro-ipc1.7.7avro-ipc-1.7.7-tests.jar;E:softwaremaven3.3.9
    epositorycom	witterchill_2.110.8.0chill_2.11-0.8.0.jar;E:softwaremaven3.3.9
    epositorycomesotericsoftwarekryo-shaded3.0.3kryo-shaded-3.0.3.jar;E:softwaremaven3.3.9
    epositorycomesotericsoftwareminlog1.3.0minlog-1.3.0.jar;E:softwaremaven3.3.9
    epositoryorgobjenesisobjenesis2.1objenesis-2.1.jar;E:softwaremaven3.3.9
    epositorycom	witterchill-java0.8.0chill-java-0.8.0.jar;E:softwaremaven3.3.9
    epositoryorgapachexbeanxbean-asm5-shaded4.4xbean-asm5-shaded-4.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-launcher_2.112.2.0spark-launcher_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-network-common_2.112.2.0spark-network-common_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgfusesourceleveldbjnileveldbjni-all1.8leveldbjni-all-1.8.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksoncorejackson-annotations2.6.5jackson-annotations-2.6.5.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-network-shuffle_2.112.2.0spark-network-shuffle_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-unsafe_2.112.2.0spark-unsafe_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epository
    etjavadevjets3tjets3t0.9.3jets3t-0.9.3.jar;E:softwaremaven3.3.9
    epositoryorgapachehttpcomponentshttpcore4.3.3httpcore-4.3.3.jar;E:softwaremaven3.3.9
    epositoryjavaxactivationactivation1.1.1activation-1.1.1.jar;E:softwaremaven3.3.9
    epositorymx4jmx4j3.0.2mx4j-3.0.2.jar;E:softwaremaven3.3.9
    epositoryjavaxmailmail1.4.7mail-1.4.7.jar;E:softwaremaven3.3.9
    epositoryorgouncycastlecprov-jdk15on1.51cprov-jdk15on-1.51.jar;E:softwaremaven3.3.9
    epositorycomjamesmurtyutilsjava-xmlbuilder1.0java-xmlbuilder-1.0.jar;E:softwaremaven3.3.9
    epository
    etiharderase642.3.8ase64-2.3.8.jar;E:softwaremaven3.3.9
    epositoryorgapachecuratorcurator-recipes2.6.0curator-recipes-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachecuratorcurator-framework2.6.0curator-framework-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachezookeeperzookeeper3.4.6zookeeper-3.4.6.jar;E:softwaremaven3.3.9
    epositorycomgoogleguavaguava16.0.1guava-16.0.1.jar;E:softwaremaven3.3.9
    epositoryjavaxservletjavax.servlet-api3.1.0javax.servlet-api-3.1.0.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-lang33.5commons-lang3-3.5.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-math33.4.1commons-math3-3.4.1.jar;E:softwaremaven3.3.9
    epositorycomgooglecodefindbugsjsr3051.3.9jsr305-1.3.9.jar;E:softwaremaven3.3.9
    epositoryorgslf4jslf4j-api1.7.16slf4j-api-1.7.16.jar;E:softwaremaven3.3.9
    epositoryorgslf4jjul-to-slf4j1.7.16jul-to-slf4j-1.7.16.jar;E:softwaremaven3.3.9
    epositoryorgslf4jjcl-over-slf4j1.7.16jcl-over-slf4j-1.7.16.jar;E:softwaremaven3.3.9
    epositorylog4jlog4j1.2.17log4j-1.2.17.jar;E:softwaremaven3.3.9
    epositoryorgslf4jslf4j-log4j121.7.16slf4j-log4j12-1.7.16.jar;E:softwaremaven3.3.9
    epositorycom
    ingcompress-lzf1.0.3compress-lzf-1.0.3.jar;E:softwaremaven3.3.9
    epositoryorgxerialsnappysnappy-java1.1.2.6snappy-java-1.1.2.6.jar;E:softwaremaven3.3.9
    epository
    etjpountzlz4lz41.3.0lz4-1.3.0.jar;E:softwaremaven3.3.9
    epositoryorg
    oaringbitmapRoaringBitmap0.5.11RoaringBitmap-0.5.11.jar;E:softwaremaven3.3.9
    epositorycommons-netcommons-net2.2commons-net-2.2.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscala-library2.11.8scala-library-2.11.8.jar;E:softwaremaven3.3.9
    epositoryorgjson4sjson4s-jackson_2.113.2.11json4s-jackson_2.11-3.2.11.jar;E:softwaremaven3.3.9
    epositoryorgjson4sjson4s-core_2.113.2.11json4s-core_2.11-3.2.11.jar;E:softwaremaven3.3.9
    epositoryorgjson4sjson4s-ast_2.113.2.11json4s-ast_2.11-3.2.11.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscalap2.11.0scalap-2.11.0.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscala-compiler2.11.0scala-compiler-2.11.0.jar;E:softwaremaven3.3.9
    epositoryorgscala-langmodulesscala-xml_2.111.0.1scala-xml_2.11-1.0.1.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycorejersey-client2.22.2jersey-client-2.22.2.jar;E:softwaremaven3.3.9
    epositoryjavaxws
    sjavax.ws.rs-api2.0.1javax.ws.rs-api-2.0.1.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2hk2-api2.4.0-b34hk2-api-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2hk2-utils2.4.0-b34hk2-utils-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2externalaopalliance-repackaged2.4.0-b34aopalliance-repackaged-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2externaljavax.inject2.4.0-b34javax.inject-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2hk2-locator2.4.0-b34hk2-locator-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgjavassistjavassist3.18.1-GAjavassist-3.18.1-GA.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycorejersey-common2.22.2jersey-common-2.22.2.jar;E:softwaremaven3.3.9
    epositoryjavaxannotationjavax.annotation-api1.2javax.annotation-api-1.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseyundles
    epackagedjersey-guava2.22.2jersey-guava-2.22.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2osgi-resource-locator1.0.1osgi-resource-locator-1.0.1.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycorejersey-server2.22.2jersey-server-2.22.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseymediajersey-media-jaxb2.22.2jersey-media-jaxb-2.22.2.jar;E:softwaremaven3.3.9
    epositoryjavaxvalidationvalidation-api1.1.0.Finalvalidation-api-1.1.0.Final.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycontainersjersey-container-servlet2.22.2jersey-container-servlet-2.22.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycontainersjersey-container-servlet-core2.22.2jersey-container-servlet-core-2.22.2.jar;E:softwaremaven3.3.9
    epositoryio
    etty
    etty-all4.0.43.Final
    etty-all-4.0.43.Final.jar;E:softwaremaven3.3.9
    epositoryio
    etty
    etty3.9.9.Final
    etty-3.9.9.Final.jar;E:softwaremaven3.3.9
    epositorycomclearspringanalyticsstream2.7.0stream-2.7.0.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-core3.1.2metrics-core-3.1.2.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-jvm3.1.2metrics-jvm-3.1.2.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-json3.1.2metrics-json-3.1.2.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-graphite3.1.2metrics-graphite-3.1.2.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksoncorejackson-databind2.6.5jackson-databind-2.6.5.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksoncorejackson-core2.6.5jackson-core-2.6.5.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksonmodulejackson-module-scala_2.112.6.5jackson-module-scala_2.11-2.6.5.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscala-reflect2.11.7scala-reflect-2.11.7.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksonmodulejackson-module-paranamer2.6.5jackson-module-paranamer-2.6.5.jar;E:softwaremaven3.3.9
    epositoryorgapacheivyivy2.4.0ivy-2.4.0.jar;E:softwaremaven3.3.9
    epositoryorooro2.0.8oro-2.0.8.jar;E:softwaremaven3.3.9
    epository
    et
    azorvinepyrolite4.13pyrolite-4.13.jar;E:softwaremaven3.3.9
    epository
    etsfpy4jpy4j0.10.4py4j-0.10.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-tags_2.112.2.0spark-tags_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-crypto1.0.0commons-crypto-1.0.0.jar;E:softwaremaven3.3.9
    epositoryorgspark-projectsparkunused1.0.0unused-1.0.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-sql_2.112.2.0spark-sql_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositorycomunivocityunivocity-parsers2.2.1univocity-parsers-2.2.1.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-sketch_2.112.2.0spark-sketch_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-catalyst_2.112.2.0spark-catalyst_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjaninojanino3.0.0janino-3.0.0.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjaninocommons-compiler3.0.0commons-compiler-3.0.0.jar;E:softwaremaven3.3.9
    epositoryorgantlrantlr4-runtime4.5.3antlr4-runtime-4.5.3.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-column1.8.2parquet-column-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-common1.8.2parquet-common-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-encoding1.8.2parquet-encoding-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-hadoop1.8.2parquet-hadoop-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-format2.3.1parquet-format-2.3.1.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-jackson1.8.2parquet-jackson-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-streaming_2.112.2.0spark-streaming_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-hive_2.112.2.0spark-hive_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositorycom	witterparquet-hadoop-bundle1.6.0parquet-hadoop-bundle-1.6.0.jar;E:softwaremaven3.3.9
    epositoryorgspark-projecthivehive-exec1.2.1.spark2hive-exec-1.2.1.spark2.jar;E:softwaremaven3.3.9
    epositorycommons-iocommons-io2.4commons-io-2.4.jar;E:softwaremaven3.3.9
    epositorycommons-langcommons-lang2.6commons-lang-2.6.jar;E:softwaremaven3.3.9
    epositoryjavolutionjavolution5.5.1javolution-5.5.1.jar;E:softwaremaven3.3.9
    epositorylog4japache-log4j-extras1.2.17apache-log4j-extras-1.2.17.jar;E:softwaremaven3.3.9
    epositoryorgantlrantlr-runtime3.4antlr-runtime-3.4.jar;E:softwaremaven3.3.9
    epositoryorgantlrstringtemplate3.2.1stringtemplate-3.2.1.jar;E:softwaremaven3.3.9
    epositoryantlrantlr2.7.7antlr-2.7.7.jar;E:softwaremaven3.3.9
    epositoryorgantlrST44.0.4ST4-4.0.4.jar;E:softwaremaven3.3.9
    epositorycomgooglecodejavaewahJavaEWAH0.3.2JavaEWAH-0.3.2.jar;E:softwaremaven3.3.9
    epositoryorgiq80snappysnappy0.2snappy-0.2.jar;E:softwaremaven3.3.9
    epositorystaxstax-api1.0.1stax-api-1.0.1.jar;E:softwaremaven3.3.9
    epository
    etsfopencsvopencsv2.3opencsv-2.3.jar;E:softwaremaven3.3.9
    epositoryorgspark-projecthivehive-metastore1.2.1.spark2hive-metastore-1.2.1.spark2.jar;E:softwaremaven3.3.9
    epositorycomjolboxonecp0.8.0.RELEASEonecp-0.8.0.RELEASE.jar;E:softwaremaven3.3.9
    epositorycommons-clicommons-cli1.2commons-cli-1.2.jar;E:softwaremaven3.3.9
    epositorycommons-loggingcommons-logging1.1.3commons-logging-1.1.3.jar;E:softwaremaven3.3.9
    epositoryorgapachederbyderby10.10.2.0derby-10.10.2.0.jar;E:softwaremaven3.3.9
    epositoryorgdatanucleusdatanucleus-api-jdo3.2.6datanucleus-api-jdo-3.2.6.jar;E:softwaremaven3.3.9
    epositoryorgdatanucleusdatanucleus-rdbms3.2.9datanucleus-rdbms-3.2.9.jar;E:softwaremaven3.3.9
    epositorycommons-poolcommons-pool1.5.4commons-pool-1.5.4.jar;E:softwaremaven3.3.9
    epositorycommons-dbcpcommons-dbcp1.4commons-dbcp-1.4.jar;E:softwaremaven3.3.9
    epositoryjavaxjdojdo-api3.0.1jdo-api-3.0.1.jar;E:softwaremaven3.3.9
    epositoryjavax	ransactionjta1.1jta-1.1.jar;E:softwaremaven3.3.9
    epositorycommons-httpclientcommons-httpclient3.1commons-httpclient-3.1.jar;E:softwaremaven3.3.9
    epositoryorgapachecalcitecalcite-avatica1.2.0-incubatingcalcite-avatica-1.2.0-incubating.jar;E:softwaremaven3.3.9
    epositoryorgapachecalcitecalcite-core1.2.0-incubatingcalcite-core-1.2.0-incubating.jar;E:softwaremaven3.3.9
    epositoryorgapachecalcitecalcite-linq4j1.2.0-incubatingcalcite-linq4j-1.2.0-incubating.jar;E:softwaremaven3.3.9
    epository
    ethydromaticeigenbase-properties1.1.5eigenbase-properties-1.1.5.jar;E:softwaremaven3.3.9
    epositoryorgapachehttpcomponentshttpclient4.5.2httpclient-4.5.2.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-mapper-asl1.9.13jackson-mapper-asl-1.9.13.jar;E:softwaremaven3.3.9
    epositorycommons-codeccommons-codec1.10commons-codec-1.10.jar;E:softwaremaven3.3.9
    epositoryjoda-timejoda-time2.9.3joda-time-2.9.3.jar;E:softwaremaven3.3.9
    epositoryorgjoddjodd-core3.5.2jodd-core-3.5.2.jar;E:softwaremaven3.3.9
    epositoryorgdatanucleusdatanucleus-core3.2.10datanucleus-core-3.2.10.jar;E:softwaremaven3.3.9
    epositoryorgapache	hriftlibthrift0.9.3libthrift-0.9.3.jar;E:softwaremaven3.3.9
    epositoryorgapache	hriftlibfb3030.9.3libfb303-0.9.3.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-streaming-kafka-0-10_2.112.2.0spark-streaming-kafka-0-10_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachekafkakafka_2.110.10.0.1kafka_2.11-0.10.0.1.jar;E:softwaremaven3.3.9
    epositorycom101teczkclient0.8zkclient-0.8.jar;E:softwaremaven3.3.9
    epositorycomyammermetricsmetrics-core2.2.0metrics-core-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgscala-langmodulesscala-parser-combinators_2.111.0.4scala-parser-combinators_2.11-1.0.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-sql-kafka-0-10_2.112.2.0spark-sql-kafka-0-10_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachekafkakafka-clients0.10.0.1kafka-clients-0.10.0.1.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-client2.6.0hadoop-client-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-common2.6.0hadoop-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryxmlencxmlenc0.52xmlenc-0.52.jar;E:softwaremaven3.3.9
    epositorycommons-collectionscommons-collections3.2.1commons-collections-3.2.1.jar;E:softwaremaven3.3.9
    epositorycommons-configurationcommons-configuration1.6commons-configuration-1.6.jar;E:softwaremaven3.3.9
    epositorycommons-digestercommons-digester1.8commons-digester-1.8.jar;E:softwaremaven3.3.9
    epositorycommons-beanutilscommons-beanutils1.7.0commons-beanutils-1.7.0.jar;E:softwaremaven3.3.9
    epositorycommons-beanutilscommons-beanutils-core1.8.0commons-beanutils-core-1.8.0.jar;E:softwaremaven3.3.9
    epositorycomgoogleprotobufprotobuf-java2.5.0protobuf-java-2.5.0.jar;E:softwaremaven3.3.9
    epositorycomgooglecodegsongson2.2.4gson-2.2.4.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-auth2.6.0hadoop-auth-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryserverapacheds-kerberos-codec2.0.0-M15apacheds-kerberos-codec-2.0.0-M15.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryserverapacheds-i18n2.0.0-M15apacheds-i18n-2.0.0-M15.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryapiapi-asn1-api1.0.0-M20api-asn1-api-1.0.0-M20.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryapiapi-util1.0.0-M20api-util-1.0.0-M20.jar;E:softwaremaven3.3.9
    epositoryorgapachecuratorcurator-client2.6.0curator-client-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorghtracehtrace-core3.0.4htrace-core-3.0.4.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-hdfs2.6.0hadoop-hdfs-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgmortbayjettyjetty-util6.1.26jetty-util-6.1.26.jar;E:softwaremaven3.3.9
    epositoryxercesxercesImpl2.9.1xercesImpl-2.9.1.jar;E:softwaremaven3.3.9
    epositoryxml-apisxml-apis1.3.04xml-apis-1.3.04.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-app2.6.0hadoop-mapreduce-client-app-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-common2.6.0hadoop-mapreduce-client-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-client2.6.0hadoop-yarn-client-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-server-common2.6.0hadoop-yarn-server-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-shuffle2.6.0hadoop-mapreduce-client-shuffle-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-api2.6.0hadoop-yarn-api-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-core2.6.0hadoop-mapreduce-client-core-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-common2.6.0hadoop-yarn-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryjavaxxmlindjaxb-api2.2.2jaxb-api-2.2.2.jar;E:softwaremaven3.3.9
    epositoryjavaxxmlstreamstax-api1.0-2stax-api-1.0-2.jar;E:softwaremaven3.3.9
    epositoryjavaxservletservlet-api2.5servlet-api-2.5.jar;E:softwaremaven3.3.9
    epositorycomsunjerseyjersey-core1.9jersey-core-1.9.jar;E:softwaremaven3.3.9
    epositorycomsunjerseyjersey-client1.9jersey-client-1.9.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-jaxrs1.9.13jackson-jaxrs-1.9.13.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-xc1.9.13jackson-xc-1.9.13.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-jobclient2.6.0hadoop-mapreduce-client-jobclient-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-annotations2.6.0hadoop-annotations-2.6.0.jar com.spark.test.Test
    Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
    18/03/14 17:34:56 INFO SparkContext: Running Spark version 2.2.0
    18/03/14 17:34:57 ERROR SparkContext: Error initializing SparkContext.
    org.apache.spark.SparkException: A master URL must be set in your configuration
        at org.apache.spark.SparkContext.<init>(SparkContext.scala:376)
        at org.apache.spark.SparkContext$.getOrCreate(SparkContext.scala:2509)
        at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:909)
        at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:901)
        at scala.Option.getOrElse(Option.scala:121)
        at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:901)
        at com.spark.test.Test$.main(Test.scala:11)
        at com.spark.test.Test.main(Test.scala)
    18/03/14 17:34:57 INFO SparkContext: Successfully stopped SparkContext
    Exception in thread "main" org.apache.spark.SparkException: A master URL must be set in your configuration
        at org.apache.spark.SparkContext.<init>(SparkContext.scala:376)
        at org.apache.spark.SparkContext$.getOrCreate(SparkContext.scala:2509)
        at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:909)
        at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:901)
        at scala.Option.getOrElse(Option.scala:121)
        at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:901)
        at com.spark.test.Test$.main(Test.scala:11)
        at com.spark.test.Test.main(Test.scala)
    
    Process finished with exit code 1

    这里的错误是说要指明你的程序运行在什么地方

    在程序里加上这一句,指明我们现在在本地运行

     我们再运行一次,可以看到没问题了

    我们继续修改程序,加上这一句

     再次运行看看结果

     把相同的单词进行累加

     我们看看运行结果

    刚刚我们使用的是rdd的方式,接下来我们使用dataSet的方式

    dataSet可以近似的理解为数据库的一张张表

    我们运行的结果

     用空格切分单词

     

     运行结果

     

    E:softwarejdk1.8injava "-javaagent:E:softwareIDEAIntelliJ IDEA 2017.2.6libidea_rt.jar=62232:E:softwareIDEAIntelliJ IDEA 2017.2.6in" -Dfile.encoding=UTF-8 -classpath E:softwarejdk1.8jrelibcharsets.jar;E:softwarejdk1.8jrelibdeploy.jar;E:softwarejdk1.8jrelibextaccess-bridge-64.jar;E:softwarejdk1.8jrelibextcldrdata.jar;E:softwarejdk1.8jrelibextdnsns.jar;E:softwarejdk1.8jrelibextjaccess.jar;E:softwarejdk1.8jrelibextjfxrt.jar;E:softwarejdk1.8jrelibextlocaledata.jar;E:softwarejdk1.8jrelibext
    ashorn.jar;E:softwarejdk1.8jrelibextsunec.jar;E:softwarejdk1.8jrelibextsunjce_provider.jar;E:softwarejdk1.8jrelibextsunmscapi.jar;E:softwarejdk1.8jrelibextsunpkcs11.jar;E:softwarejdk1.8jrelibextzipfs.jar;E:softwarejdk1.8jrelibjavaws.jar;E:softwarejdk1.8jrelibjce.jar;E:softwarejdk1.8jrelibjfr.jar;E:softwarejdk1.8jrelibjfxswt.jar;E:softwarejdk1.8jrelibjsse.jar;E:softwarejdk1.8jrelibmanagement-agent.jar;E:softwarejdk1.8jrelibplugin.jar;E:softwarejdk1.8jrelib
    esources.jar;E:softwarejdk1.8jrelib
    t.jar;E:MycodeSparkStu	argetclasses;E:softwareScalalibscala-actors-2.11.0.jar;E:softwareScalalibscala-actors-migration_2.11-1.1.0.jar;E:softwareScalalibscala-library.jar;E:softwareScalalibscala-parser-combinators_2.11-1.0.4.jar;E:softwareScalalibscala-reflect.jar;E:softwareScalalibscala-swing_2.11-1.0.2.jar;E:softwareScalalibscala-xml_2.11-1.0.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-core_2.112.2.0spark-core_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro1.7.7avro-1.7.7.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-core-asl1.9.13jackson-core-asl-1.9.13.jar;E:softwaremaven3.3.9
    epositorycom	houghtworksparanamerparanamer2.3paranamer-2.3.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-compress1.4.1commons-compress-1.4.1.jar;E:softwaremaven3.3.9
    epositoryorg	ukaanixz1.0xz-1.0.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro-mapred1.7.7avro-mapred-1.7.7-hadoop2.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro-ipc1.7.7avro-ipc-1.7.7.jar;E:softwaremaven3.3.9
    epositoryorgapacheavroavro-ipc1.7.7avro-ipc-1.7.7-tests.jar;E:softwaremaven3.3.9
    epositorycom	witterchill_2.110.8.0chill_2.11-0.8.0.jar;E:softwaremaven3.3.9
    epositorycomesotericsoftwarekryo-shaded3.0.3kryo-shaded-3.0.3.jar;E:softwaremaven3.3.9
    epositorycomesotericsoftwareminlog1.3.0minlog-1.3.0.jar;E:softwaremaven3.3.9
    epositoryorgobjenesisobjenesis2.1objenesis-2.1.jar;E:softwaremaven3.3.9
    epositorycom	witterchill-java0.8.0chill-java-0.8.0.jar;E:softwaremaven3.3.9
    epositoryorgapachexbeanxbean-asm5-shaded4.4xbean-asm5-shaded-4.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-launcher_2.112.2.0spark-launcher_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-network-common_2.112.2.0spark-network-common_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgfusesourceleveldbjnileveldbjni-all1.8leveldbjni-all-1.8.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksoncorejackson-annotations2.6.5jackson-annotations-2.6.5.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-network-shuffle_2.112.2.0spark-network-shuffle_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-unsafe_2.112.2.0spark-unsafe_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epository
    etjavadevjets3tjets3t0.9.3jets3t-0.9.3.jar;E:softwaremaven3.3.9
    epositoryorgapachehttpcomponentshttpcore4.3.3httpcore-4.3.3.jar;E:softwaremaven3.3.9
    epositoryjavaxactivationactivation1.1.1activation-1.1.1.jar;E:softwaremaven3.3.9
    epositorymx4jmx4j3.0.2mx4j-3.0.2.jar;E:softwaremaven3.3.9
    epositoryjavaxmailmail1.4.7mail-1.4.7.jar;E:softwaremaven3.3.9
    epositoryorgouncycastlecprov-jdk15on1.51cprov-jdk15on-1.51.jar;E:softwaremaven3.3.9
    epositorycomjamesmurtyutilsjava-xmlbuilder1.0java-xmlbuilder-1.0.jar;E:softwaremaven3.3.9
    epository
    etiharderase642.3.8ase64-2.3.8.jar;E:softwaremaven3.3.9
    epositoryorgapachecuratorcurator-recipes2.6.0curator-recipes-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachecuratorcurator-framework2.6.0curator-framework-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachezookeeperzookeeper3.4.6zookeeper-3.4.6.jar;E:softwaremaven3.3.9
    epositorycomgoogleguavaguava16.0.1guava-16.0.1.jar;E:softwaremaven3.3.9
    epositoryjavaxservletjavax.servlet-api3.1.0javax.servlet-api-3.1.0.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-lang33.5commons-lang3-3.5.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-math33.4.1commons-math3-3.4.1.jar;E:softwaremaven3.3.9
    epositorycomgooglecodefindbugsjsr3051.3.9jsr305-1.3.9.jar;E:softwaremaven3.3.9
    epositoryorgslf4jslf4j-api1.7.16slf4j-api-1.7.16.jar;E:softwaremaven3.3.9
    epositoryorgslf4jjul-to-slf4j1.7.16jul-to-slf4j-1.7.16.jar;E:softwaremaven3.3.9
    epositoryorgslf4jjcl-over-slf4j1.7.16jcl-over-slf4j-1.7.16.jar;E:softwaremaven3.3.9
    epositorylog4jlog4j1.2.17log4j-1.2.17.jar;E:softwaremaven3.3.9
    epositoryorgslf4jslf4j-log4j121.7.16slf4j-log4j12-1.7.16.jar;E:softwaremaven3.3.9
    epositorycom
    ingcompress-lzf1.0.3compress-lzf-1.0.3.jar;E:softwaremaven3.3.9
    epositoryorgxerialsnappysnappy-java1.1.2.6snappy-java-1.1.2.6.jar;E:softwaremaven3.3.9
    epository
    etjpountzlz4lz41.3.0lz4-1.3.0.jar;E:softwaremaven3.3.9
    epositoryorg
    oaringbitmapRoaringBitmap0.5.11RoaringBitmap-0.5.11.jar;E:softwaremaven3.3.9
    epositorycommons-netcommons-net2.2commons-net-2.2.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscala-library2.11.8scala-library-2.11.8.jar;E:softwaremaven3.3.9
    epositoryorgjson4sjson4s-jackson_2.113.2.11json4s-jackson_2.11-3.2.11.jar;E:softwaremaven3.3.9
    epositoryorgjson4sjson4s-core_2.113.2.11json4s-core_2.11-3.2.11.jar;E:softwaremaven3.3.9
    epositoryorgjson4sjson4s-ast_2.113.2.11json4s-ast_2.11-3.2.11.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscalap2.11.0scalap-2.11.0.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscala-compiler2.11.0scala-compiler-2.11.0.jar;E:softwaremaven3.3.9
    epositoryorgscala-langmodulesscala-xml_2.111.0.1scala-xml_2.11-1.0.1.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycorejersey-client2.22.2jersey-client-2.22.2.jar;E:softwaremaven3.3.9
    epositoryjavaxws
    sjavax.ws.rs-api2.0.1javax.ws.rs-api-2.0.1.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2hk2-api2.4.0-b34hk2-api-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2hk2-utils2.4.0-b34hk2-utils-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2externalaopalliance-repackaged2.4.0-b34aopalliance-repackaged-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2externaljavax.inject2.4.0-b34javax.inject-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2hk2-locator2.4.0-b34hk2-locator-2.4.0-b34.jar;E:softwaremaven3.3.9
    epositoryorgjavassistjavassist3.18.1-GAjavassist-3.18.1-GA.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycorejersey-common2.22.2jersey-common-2.22.2.jar;E:softwaremaven3.3.9
    epositoryjavaxannotationjavax.annotation-api1.2javax.annotation-api-1.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseyundles
    epackagedjersey-guava2.22.2jersey-guava-2.22.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishhk2osgi-resource-locator1.0.1osgi-resource-locator-1.0.1.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycorejersey-server2.22.2jersey-server-2.22.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseymediajersey-media-jaxb2.22.2jersey-media-jaxb-2.22.2.jar;E:softwaremaven3.3.9
    epositoryjavaxvalidationvalidation-api1.1.0.Finalvalidation-api-1.1.0.Final.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycontainersjersey-container-servlet2.22.2jersey-container-servlet-2.22.2.jar;E:softwaremaven3.3.9
    epositoryorgglassfishjerseycontainersjersey-container-servlet-core2.22.2jersey-container-servlet-core-2.22.2.jar;E:softwaremaven3.3.9
    epositoryio
    etty
    etty-all4.0.43.Final
    etty-all-4.0.43.Final.jar;E:softwaremaven3.3.9
    epositoryio
    etty
    etty3.9.9.Final
    etty-3.9.9.Final.jar;E:softwaremaven3.3.9
    epositorycomclearspringanalyticsstream2.7.0stream-2.7.0.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-core3.1.2metrics-core-3.1.2.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-jvm3.1.2metrics-jvm-3.1.2.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-json3.1.2metrics-json-3.1.2.jar;E:softwaremaven3.3.9
    epositoryiodropwizardmetricsmetrics-graphite3.1.2metrics-graphite-3.1.2.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksoncorejackson-databind2.6.5jackson-databind-2.6.5.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksoncorejackson-core2.6.5jackson-core-2.6.5.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksonmodulejackson-module-scala_2.112.6.5jackson-module-scala_2.11-2.6.5.jar;E:softwaremaven3.3.9
    epositoryorgscala-langscala-reflect2.11.7scala-reflect-2.11.7.jar;E:softwaremaven3.3.9
    epositorycomfasterxmljacksonmodulejackson-module-paranamer2.6.5jackson-module-paranamer-2.6.5.jar;E:softwaremaven3.3.9
    epositoryorgapacheivyivy2.4.0ivy-2.4.0.jar;E:softwaremaven3.3.9
    epositoryorooro2.0.8oro-2.0.8.jar;E:softwaremaven3.3.9
    epository
    et
    azorvinepyrolite4.13pyrolite-4.13.jar;E:softwaremaven3.3.9
    epository
    etsfpy4jpy4j0.10.4py4j-0.10.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-tags_2.112.2.0spark-tags_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachecommonscommons-crypto1.0.0commons-crypto-1.0.0.jar;E:softwaremaven3.3.9
    epositoryorgspark-projectsparkunused1.0.0unused-1.0.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-sql_2.112.2.0spark-sql_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositorycomunivocityunivocity-parsers2.2.1univocity-parsers-2.2.1.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-sketch_2.112.2.0spark-sketch_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-catalyst_2.112.2.0spark-catalyst_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjaninojanino3.0.0janino-3.0.0.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjaninocommons-compiler3.0.0commons-compiler-3.0.0.jar;E:softwaremaven3.3.9
    epositoryorgantlrantlr4-runtime4.5.3antlr4-runtime-4.5.3.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-column1.8.2parquet-column-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-common1.8.2parquet-common-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-encoding1.8.2parquet-encoding-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-hadoop1.8.2parquet-hadoop-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-format2.3.1parquet-format-2.3.1.jar;E:softwaremaven3.3.9
    epositoryorgapacheparquetparquet-jackson1.8.2parquet-jackson-1.8.2.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-streaming_2.112.2.0spark-streaming_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-hive_2.112.2.0spark-hive_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositorycom	witterparquet-hadoop-bundle1.6.0parquet-hadoop-bundle-1.6.0.jar;E:softwaremaven3.3.9
    epositoryorgspark-projecthivehive-exec1.2.1.spark2hive-exec-1.2.1.spark2.jar;E:softwaremaven3.3.9
    epositorycommons-iocommons-io2.4commons-io-2.4.jar;E:softwaremaven3.3.9
    epositorycommons-langcommons-lang2.6commons-lang-2.6.jar;E:softwaremaven3.3.9
    epositoryjavolutionjavolution5.5.1javolution-5.5.1.jar;E:softwaremaven3.3.9
    epositorylog4japache-log4j-extras1.2.17apache-log4j-extras-1.2.17.jar;E:softwaremaven3.3.9
    epositoryorgantlrantlr-runtime3.4antlr-runtime-3.4.jar;E:softwaremaven3.3.9
    epositoryorgantlrstringtemplate3.2.1stringtemplate-3.2.1.jar;E:softwaremaven3.3.9
    epositoryantlrantlr2.7.7antlr-2.7.7.jar;E:softwaremaven3.3.9
    epositoryorgantlrST44.0.4ST4-4.0.4.jar;E:softwaremaven3.3.9
    epositorycomgooglecodejavaewahJavaEWAH0.3.2JavaEWAH-0.3.2.jar;E:softwaremaven3.3.9
    epositoryorgiq80snappysnappy0.2snappy-0.2.jar;E:softwaremaven3.3.9
    epositorystaxstax-api1.0.1stax-api-1.0.1.jar;E:softwaremaven3.3.9
    epository
    etsfopencsvopencsv2.3opencsv-2.3.jar;E:softwaremaven3.3.9
    epositoryorgspark-projecthivehive-metastore1.2.1.spark2hive-metastore-1.2.1.spark2.jar;E:softwaremaven3.3.9
    epositorycomjolboxonecp0.8.0.RELEASEonecp-0.8.0.RELEASE.jar;E:softwaremaven3.3.9
    epositorycommons-clicommons-cli1.2commons-cli-1.2.jar;E:softwaremaven3.3.9
    epositorycommons-loggingcommons-logging1.1.3commons-logging-1.1.3.jar;E:softwaremaven3.3.9
    epositoryorgapachederbyderby10.10.2.0derby-10.10.2.0.jar;E:softwaremaven3.3.9
    epositoryorgdatanucleusdatanucleus-api-jdo3.2.6datanucleus-api-jdo-3.2.6.jar;E:softwaremaven3.3.9
    epositoryorgdatanucleusdatanucleus-rdbms3.2.9datanucleus-rdbms-3.2.9.jar;E:softwaremaven3.3.9
    epositorycommons-poolcommons-pool1.5.4commons-pool-1.5.4.jar;E:softwaremaven3.3.9
    epositorycommons-dbcpcommons-dbcp1.4commons-dbcp-1.4.jar;E:softwaremaven3.3.9
    epositoryjavaxjdojdo-api3.0.1jdo-api-3.0.1.jar;E:softwaremaven3.3.9
    epositoryjavax	ransactionjta1.1jta-1.1.jar;E:softwaremaven3.3.9
    epositorycommons-httpclientcommons-httpclient3.1commons-httpclient-3.1.jar;E:softwaremaven3.3.9
    epositoryorgapachecalcitecalcite-avatica1.2.0-incubatingcalcite-avatica-1.2.0-incubating.jar;E:softwaremaven3.3.9
    epositoryorgapachecalcitecalcite-core1.2.0-incubatingcalcite-core-1.2.0-incubating.jar;E:softwaremaven3.3.9
    epositoryorgapachecalcitecalcite-linq4j1.2.0-incubatingcalcite-linq4j-1.2.0-incubating.jar;E:softwaremaven3.3.9
    epository
    ethydromaticeigenbase-properties1.1.5eigenbase-properties-1.1.5.jar;E:softwaremaven3.3.9
    epositoryorgapachehttpcomponentshttpclient4.5.2httpclient-4.5.2.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-mapper-asl1.9.13jackson-mapper-asl-1.9.13.jar;E:softwaremaven3.3.9
    epositorycommons-codeccommons-codec1.10commons-codec-1.10.jar;E:softwaremaven3.3.9
    epositoryjoda-timejoda-time2.9.3joda-time-2.9.3.jar;E:softwaremaven3.3.9
    epositoryorgjoddjodd-core3.5.2jodd-core-3.5.2.jar;E:softwaremaven3.3.9
    epositoryorgdatanucleusdatanucleus-core3.2.10datanucleus-core-3.2.10.jar;E:softwaremaven3.3.9
    epositoryorgapache	hriftlibthrift0.9.3libthrift-0.9.3.jar;E:softwaremaven3.3.9
    epositoryorgapache	hriftlibfb3030.9.3libfb303-0.9.3.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-streaming-kafka-0-10_2.112.2.0spark-streaming-kafka-0-10_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachekafkakafka_2.110.10.0.1kafka_2.11-0.10.0.1.jar;E:softwaremaven3.3.9
    epositorycom101teczkclient0.8zkclient-0.8.jar;E:softwaremaven3.3.9
    epositorycomyammermetricsmetrics-core2.2.0metrics-core-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgscala-langmodulesscala-parser-combinators_2.111.0.4scala-parser-combinators_2.11-1.0.4.jar;E:softwaremaven3.3.9
    epositoryorgapachesparkspark-sql-kafka-0-10_2.112.2.0spark-sql-kafka-0-10_2.11-2.2.0.jar;E:softwaremaven3.3.9
    epositoryorgapachekafkakafka-clients0.10.0.1kafka-clients-0.10.0.1.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-client2.6.0hadoop-client-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-common2.6.0hadoop-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryxmlencxmlenc0.52xmlenc-0.52.jar;E:softwaremaven3.3.9
    epositorycommons-collectionscommons-collections3.2.1commons-collections-3.2.1.jar;E:softwaremaven3.3.9
    epositorycommons-configurationcommons-configuration1.6commons-configuration-1.6.jar;E:softwaremaven3.3.9
    epositorycommons-digestercommons-digester1.8commons-digester-1.8.jar;E:softwaremaven3.3.9
    epositorycommons-beanutilscommons-beanutils1.7.0commons-beanutils-1.7.0.jar;E:softwaremaven3.3.9
    epositorycommons-beanutilscommons-beanutils-core1.8.0commons-beanutils-core-1.8.0.jar;E:softwaremaven3.3.9
    epositorycomgoogleprotobufprotobuf-java2.5.0protobuf-java-2.5.0.jar;E:softwaremaven3.3.9
    epositorycomgooglecodegsongson2.2.4gson-2.2.4.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-auth2.6.0hadoop-auth-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryserverapacheds-kerberos-codec2.0.0-M15apacheds-kerberos-codec-2.0.0-M15.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryserverapacheds-i18n2.0.0-M15apacheds-i18n-2.0.0-M15.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryapiapi-asn1-api1.0.0-M20api-asn1-api-1.0.0-M20.jar;E:softwaremaven3.3.9
    epositoryorgapachedirectoryapiapi-util1.0.0-M20api-util-1.0.0-M20.jar;E:softwaremaven3.3.9
    epositoryorgapachecuratorcurator-client2.6.0curator-client-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorghtracehtrace-core3.0.4htrace-core-3.0.4.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-hdfs2.6.0hadoop-hdfs-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgmortbayjettyjetty-util6.1.26jetty-util-6.1.26.jar;E:softwaremaven3.3.9
    epositoryxercesxercesImpl2.9.1xercesImpl-2.9.1.jar;E:softwaremaven3.3.9
    epositoryxml-apisxml-apis1.3.04xml-apis-1.3.04.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-app2.6.0hadoop-mapreduce-client-app-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-common2.6.0hadoop-mapreduce-client-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-client2.6.0hadoop-yarn-client-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-server-common2.6.0hadoop-yarn-server-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-shuffle2.6.0hadoop-mapreduce-client-shuffle-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-api2.6.0hadoop-yarn-api-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-core2.6.0hadoop-mapreduce-client-core-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-yarn-common2.6.0hadoop-yarn-common-2.6.0.jar;E:softwaremaven3.3.9
    epositoryjavaxxmlindjaxb-api2.2.2jaxb-api-2.2.2.jar;E:softwaremaven3.3.9
    epositoryjavaxxmlstreamstax-api1.0-2stax-api-1.0-2.jar;E:softwaremaven3.3.9
    epositoryjavaxservletservlet-api2.5servlet-api-2.5.jar;E:softwaremaven3.3.9
    epositorycomsunjerseyjersey-core1.9jersey-core-1.9.jar;E:softwaremaven3.3.9
    epositorycomsunjerseyjersey-client1.9jersey-client-1.9.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-jaxrs1.9.13jackson-jaxrs-1.9.13.jar;E:softwaremaven3.3.9
    epositoryorgcodehausjacksonjackson-xc1.9.13jackson-xc-1.9.13.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-mapreduce-client-jobclient2.6.0hadoop-mapreduce-client-jobclient-2.6.0.jar;E:softwaremaven3.3.9
    epositoryorgapachehadoophadoop-annotations2.6.0hadoop-annotations-2.6.0.jar com.spark.test.Test
    Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
    18/03/14 20:41:05 INFO SparkContext: Running Spark version 2.2.0
    18/03/14 20:41:06 INFO SparkContext: Submitted application: HdfsTest
    18/03/14 20:41:06 INFO SecurityManager: Changing view acls to: Brave
    18/03/14 20:41:06 INFO SecurityManager: Changing modify acls to: Brave
    18/03/14 20:41:06 INFO SecurityManager: Changing view acls groups to: 
    18/03/14 20:41:06 INFO SecurityManager: Changing modify acls groups to: 
    18/03/14 20:41:06 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(Brave); groups with view permissions: Set(); users  with modify permissions: Set(Brave); groups with modify permissions: Set()
    18/03/14 20:41:07 INFO Utils: Successfully started service 'sparkDriver' on port 62269.
    18/03/14 20:41:07 INFO SparkEnv: Registering MapOutputTracker
    18/03/14 20:41:07 INFO SparkEnv: Registering BlockManagerMaster
    18/03/14 20:41:07 INFO BlockManagerMasterEndpoint: Using org.apache.spark.storage.DefaultTopologyMapper for getting topology information
    18/03/14 20:41:07 INFO BlockManagerMasterEndpoint: BlockManagerMasterEndpoint up
    18/03/14 20:41:07 INFO DiskBlockManager: Created local directory at C:UsersBraveAppDataLocalTemplockmgr-2ad95228-3532-4a24-b6b6-b09973c4a4ff
    18/03/14 20:41:07 INFO MemoryStore: MemoryStore started with capacity 1998.3 MB
    18/03/14 20:41:07 INFO SparkEnv: Registering OutputCommitCoordinator
    18/03/14 20:41:07 INFO Utils: Successfully started service 'SparkUI' on port 4040.
    18/03/14 20:41:07 INFO SparkUI: Bound SparkUI to 0.0.0.0, and started at http://192.168.56.1:4040
    18/03/14 20:41:07 INFO Executor: Starting executor ID driver on host localhost
    18/03/14 20:41:07 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 62282.
    18/03/14 20:41:07 INFO NettyBlockTransferService: Server created on 192.168.56.1:62282
    18/03/14 20:41:07 INFO BlockManager: Using org.apache.spark.storage.RandomBlockReplicationPolicy for block replication policy
    18/03/14 20:41:07 INFO BlockManagerMaster: Registering BlockManager BlockManagerId(driver, 192.168.56.1, 62282, None)
    18/03/14 20:41:07 INFO BlockManagerMasterEndpoint: Registering block manager 192.168.56.1:62282 with 1998.3 MB RAM, BlockManagerId(driver, 192.168.56.1, 62282, None)
    18/03/14 20:41:07 INFO BlockManagerMaster: Registered BlockManager BlockManagerId(driver, 192.168.56.1, 62282, None)
    18/03/14 20:41:07 INFO BlockManager: Initialized BlockManager: BlockManagerId(driver, 192.168.56.1, 62282, None)
    18/03/14 20:41:08 INFO SharedState: Setting hive.metastore.warehouse.dir ('null') to the value of spark.sql.warehouse.dir ('file:/E:/Mycode/SparkStu/spark-warehouse/').
    18/03/14 20:41:08 INFO SharedState: Warehouse path is 'file:/E:/Mycode/SparkStu/spark-warehouse/'.
    18/03/14 20:41:09 INFO StateStoreCoordinatorRef: Registered StateStoreCoordinator endpoint
    18/03/14 20:41:11 INFO FileSourceStrategy: Pruning directories with: 
    18/03/14 20:41:11 INFO FileSourceStrategy: Post-Scan Filters: 
    18/03/14 20:41:11 INFO FileSourceStrategy: Output Data Schema: struct<value: string>
    18/03/14 20:41:11 INFO FileSourceScanExec: Pushed Filters: 
    18/03/14 20:41:12 INFO CodeGenerator: Code generated in 321.911944 ms
    18/03/14 20:41:12 INFO CodeGenerator: Code generated in 9.798824 ms
    18/03/14 20:41:12 INFO MemoryStore: Block broadcast_0 stored as values in memory (estimated size 213.6 KB, free 1998.1 MB)
    18/03/14 20:41:12 INFO MemoryStore: Block broadcast_0_piece0 stored as bytes in memory (estimated size 20.2 KB, free 1998.1 MB)
    18/03/14 20:41:12 INFO BlockManagerInfo: Added broadcast_0_piece0 in memory on 192.168.56.1:62282 (size: 20.2 KB, free: 1998.3 MB)
    18/03/14 20:41:12 INFO SparkContext: Created broadcast 0 from show at Test.scala:17
    18/03/14 20:41:13 INFO FileSourceScanExec: Planning scan with bin packing, max size: 4194417 bytes, open cost is considered as scanning 4194304 bytes.
    18/03/14 20:41:13 INFO SparkContext: Starting job: show at Test.scala:17
    18/03/14 20:41:13 INFO DAGScheduler: Got job 0 (show at Test.scala:17) with 1 output partitions
    18/03/14 20:41:13 INFO DAGScheduler: Final stage: ResultStage 0 (show at Test.scala:17)
    18/03/14 20:41:13 INFO DAGScheduler: Parents of final stage: List()
    18/03/14 20:41:13 INFO DAGScheduler: Missing parents: List()
    18/03/14 20:41:13 INFO DAGScheduler: Submitting ResultStage 0 (MapPartitionsRDD[5] at show at Test.scala:17), which has no missing parents
    18/03/14 20:41:13 INFO MemoryStore: Block broadcast_1 stored as values in memory (estimated size 13.0 KB, free 1998.1 MB)
    18/03/14 20:41:13 INFO MemoryStore: Block broadcast_1_piece0 stored as bytes in memory (estimated size 6.1 KB, free 1998.1 MB)
    18/03/14 20:41:13 INFO BlockManagerInfo: Added broadcast_1_piece0 in memory on 192.168.56.1:62282 (size: 6.1 KB, free: 1998.3 MB)
    18/03/14 20:41:13 INFO SparkContext: Created broadcast 1 from broadcast at DAGScheduler.scala:1006
    18/03/14 20:41:13 INFO DAGScheduler: Submitting 1 missing tasks from ResultStage 0 (MapPartitionsRDD[5] at show at Test.scala:17) (first 15 tasks are for partitions Vector(0))
    18/03/14 20:41:13 INFO TaskSchedulerImpl: Adding task set 0.0 with 1 tasks
    18/03/14 20:41:13 INFO TaskSetManager: Starting task 0.0 in stage 0.0 (TID 0, localhost, executor driver, partition 0, PROCESS_LOCAL, 5268 bytes)
    18/03/14 20:41:13 INFO Executor: Running task 0.0 in stage 0.0 (TID 0)
    18/03/14 20:41:13 INFO CodeGenerator: Code generated in 13.617205 ms
    18/03/14 20:41:13 INFO FileScanRDD: Reading File path: file:///E:/Mycode/datas/stu.txt, range: 0-113, partition values: [empty row]
    18/03/14 20:41:13 INFO CodeGenerator: Code generated in 11.971125 ms
    18/03/14 20:41:13 INFO Executor: Finished task 0.0 in stage 0.0 (TID 0). 1745 bytes result sent to driver
    18/03/14 20:41:13 INFO TaskSetManager: Finished task 0.0 in stage 0.0 (TID 0) in 258 ms on localhost (executor driver) (1/1)
    18/03/14 20:41:13 INFO TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool 
    18/03/14 20:41:13 INFO DAGScheduler: ResultStage 0 (show at Test.scala:17) finished in 0.284 s
    18/03/14 20:41:13 INFO DAGScheduler: Job 0 finished: show at Test.scala:17, took 0.483521 s
    18/03/14 20:41:13 INFO CodeGenerator: Code generated in 23.334109 ms
    +------+
    | value|
    +------+
    |hadoop|
    |hadoop|
    |  java|
    |  java|
    | spark|
    | spark|
    |  hive|
    | hbase|
    | sqoop|
    | sqoop|
    | mysql|
    | redit|
    | flume|
    | flume|
    |  join|
    |   hue|
    | scala|
    |python|
    +------+
    
    18/03/14 20:41:13 INFO SparkContext: Invoking stop() from shutdown hook
    18/03/14 20:41:13 INFO SparkUI: Stopped Spark web UI at http://192.168.56.1:4040
    18/03/14 20:41:13 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped!
    18/03/14 20:41:13 INFO MemoryStore: MemoryStore cleared
    18/03/14 20:41:13 INFO BlockManager: BlockManager stopped
    18/03/14 20:41:14 INFO BlockManagerMaster: BlockManagerMaster stopped
    18/03/14 20:41:14 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped!
    18/03/14 20:41:14 INFO SparkContext: Successfully stopped SparkContext
    18/03/14 20:41:14 INFO ShutdownHookManager: Shutdown hook called
    18/03/14 20:41:14 INFO ShutdownHookManager: Deleting directory C:UsersBraveAppDataLocalTempspark-2c920b38-6a7f-4914-a2ef-9ee345492414
    
    Process finished with exit code 0

    增加这个字段

     运行结果

    分组统计

     

    运行结果

     把最后的代码放上来

    package com.spark.test
    
    import org.apache.spark.sql.SparkSession
    import org.apache.spark.{SparkConf, SparkContext}
    object Test {
    
      def main(args: Array[String]): Unit = {
       val spark= SparkSession
           .builder
             .master("local")
             .appName("HdfsTest")
               .getOrCreate()
         val filePart = "E://Mycode/datas/stu.txt"
    //     val rdd= spark.sparkContext.textFile(filePart)
    //     val lines= rdd.flatMap(x => x.split(" ")).map(x=>(x,1)).reduceByKey((a,b)=>(a+b)).collect().toList
        //     println(lines)
        import spark.implicits._
        val dataSet= spark.read.textFile(filePart)
          .flatMap(x => x.split(" "))
          .map(x=>(x,1)).groupBy("_1").count()
          .show()
        
      }
    }

    现在我们把程序打包

    我们把代码稍微改一下

    package com.spark.test
    
    import org.apache.spark.sql.SparkSession
    import org.apache.spark.{SparkConf, SparkContext}
    object Test {
    
      def main(args: Array[String]): Unit = {
       val spark= SparkSession
           .builder
             .master("local")
             .appName("HdfsTest")
               .getOrCreate()
    
        val filePart = args(0)
        //  val filePart = "E://Mycode/datas/stu.txt"
    //     val rdd= spark.sparkContext.textFile(filePart)
    //     val lines= rdd.flatMap(x => x.split(" ")).map(x=>(x,1)).reduceByKey((a,b)=>(a+b)).collect().toList
        //     println(lines)
        import spark.implicits._
        val dataSet= spark.read.textFile(filePart)
          .flatMap(x => x.split(" "))
          .map(x=>(x,1)).groupBy("_1").count()
          .show()
    
      }
    }

     

     

     

     

    把这些都剔除掉

     剩下这两个

     

     

    打包完成了

    把这个包上传到我们的集群上

     

     这个是我们的数据文件

     

    我们把数据文件上传的hdfs上面去,先启动hdfs

     

     

     

     同时记得把zookeeper也启动了,不然会出问题的

     

    现在hdfs上创建一个目录

     

     把本地的文件上传

     

     我们在集群上跑一下

    bin/spark-submit --master local[2] /opt/jars/sparkStu.jar hdfs://bigdata-pro01.kfk.com:9000/user/datas/stu.txt

    可以看到跑下来的结果

     

  • 相关阅读:
    org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.AccessControlException)
    linux命令之find和locate
    Java多线程3:Thread中的静态方法
    session的使用
    cookie的简单使用
    Spring 注入集合类型
    对Spring 容器管理事务支持的总结
    对SpringDAO层支持的总结
    为spring代理类设置属性值
    在spring中获取代理对象代理的目标对象工具类
  • 原文地址:https://www.cnblogs.com/braveym/p/8562917.html
Copyright © 2020-2023  润新知