Before a spark projects, have been using SparkContext executable program no problem, because want to use ML repository now, so use SparkSession, but just the initialization failure, should be a very simple configuration issues, but because he has no experience, no reason, search for a long time didn't see the full demonstration example
Val spark: SparkSession=SparkSession. Builder
AppName (" liqin Spark Application ")//optional and will be autogenerated if not specified
[*]. Master (" local ")//get hardcoding the deployment environment
GetOrCreate ()
Build an error is as follows:
Pom. XML file as follows:
4.0.0 & lt;/modelVersion>
Com. Cmri. Spark
DnsAnalyse
1.0 - SNAPSHOT
2008 & lt;/inceptionYear>
2.11.8 & lt;/scala. Version>
Org. Scala - lang
Scala - library
. ${scala version} & lt;/version>
Org. Specs
Specs
1.2.5 & lt;/version>
Test
Org. Apache. Spark
The spark - core_2. 11 & lt;/artifactId>
2.3.1 & lt;/version>
Org. Apache. Hadoop
Hadoop - client
2.7.2 & lt;/version>
Org. Apache. Spark
The spark - mllib_2. 11 & lt;/artifactId>
2.3.1 & lt;/version>
Runtime <- & gt;
Org. Apache. Spark
The spark - sql_2. 11 & lt;/artifactId>
2.1.0 & lt;/version>
Org. Apache. Spark
The spark - hive_2. 11 & lt;/artifactId>
2.3.1 & lt;/version>
Provided
The SRC/main/scala
SRC/test/scala <- & gt;
Net. Alchim31. Maven
Scala - maven - plugin
3.2.2 & lt;/version>
Compile
TestCompile
- dependencyfile
The ${project. Build. Directory}/. Scala_dependencies & lt;/arg>
Org, apache maven. Plugins
Maven - shade - plugin
2.4.3 & lt;/version>
False
Package
Shade
* : * & lt;/artifact>
Meta-inf/*. SF
Meta-inf/*. DSA
Meta-inf/*. RSA