Spark Scala错误-错误:在类中找不到主要方法 [英] Spark Scala Error - Error: Main method not found in class

查看:83
本文介绍了Spark Scala错误-错误:在类中找不到主要方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以下简单的spark程序,但出现以下错误.请帮助

I was trying to the below simple spark program and I am getting the below error .Please help

package com.spark.DataAnalysis

import org.apache.log4j.Level
import org.apache.spark.sql.{Dataset, SparkSession}
import org.apache.spark.sql.functions._
import org.apache.spark.SparkContext
import org.apache.spark.SparkConf

object TwitterData {
  def main(args: Array[String]) {
    println("Start")
    System.setProperty("hadoop.home.dir","C://Sankha//Study//spark-2.3.4-bin-hadoop2.7//spark-2.3.4-bin-hadoop2//spark-2.3.4-bin-hadoop2.7")
    val conf = new SparkConf().setAppName("Spark Scala WordCount Example").setMaster("local[1]")
        val spark = SparkSession.builder().appName("CsvExample").master("local").getOrCreate()
        val sc = new SparkContext(conf)
        val csvData = sc.textFile("C:\\Sankha\\Study\\data\\twitter-airline-sentiment\\Tweets.csv",3)
        val map_data = csvData.map(x=> x.split(",")).filter(x=> (x.length  < 13)).filter(x=> x(5) == "Virgin America")
        println(map_data.count())

  }
}

获取如下异常,我确定这不是因为代码,而是因为其他一些问题:

Getting the exception as below ,I am sure it is not because of the code , but for some other issue:

Error: Main method not found in class com.spark.DataAnalysis.TwitterData, please define the main method as:
   public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

推荐答案

pom.xml存在问题,我对此进行了更改并得到解决

The issue was present with pom.xml,I changed that and it got solved

这篇关于Spark Scala错误-错误:在类中找不到主要方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆