请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

mvn编译程序出错

mac 系统 将程序用maven 命令 出错:
错误一:
/Users/liujingmao/IdeaProjects/sql/src/main/scala/com/mao/sparksql/SparkSqlContext.scala:28: error: Reference to class SQLContext in package sql should not have survived past type checking,
[INFO] it should have been processed and eliminated during expansion of an enclosing macro.
[INFO] val sqlContext = new SQLContext(sc)
[INFO] ^
错误二:
Failed to execute goal org.scala-tools:maven-scala-plugin:2.15.0:compile (default) on project sql: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1(Exit value: 1) -> [Help 1]

源代码:
package com.mao.sparksql
import org.apache.spark.sql.SQLContext
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext

/**
*
*/

object SparkSqlContext {

def main(args: Array[String]): Unit = {
val path = args(0)

//Create sparkConf

val sparkConf = new SparkConf()

sparkConf.setAppName("SQLContextApp").setMaster("local[2]")

//创建SparkContext

val sc = new SparkContext(sparkConf)

//创建相应的Context

val sqlContext = new SQLContext(sc)
//处理相关的业务

val people = sqlContext.read.format("json").load(path)

people.printSchema()

people.show()

sc.stop()

}

}

正在回答 回答被采纳积分+3

2回答

Michael_PK 2018-10-13 10:34:17

先错误一解决下,把代码都删了

0 回复 有任何疑惑可以回复我~
  • 提问者 maomaoking #1
    把创建的Scala Object删除就能编译功能,并能得到 jar包,
    回复 有任何疑惑可以回复我~ 2018-10-13 12:17:15
  • Michael_PK 回复 提问者 maomaoking #2
    那在重新创建一个object试试看
    回复 有任何疑惑可以回复我~ 2018-10-13 14:01:49
  • 提问者 maomaoking 回复 Michael_PK #3
    这个问题解决了,pom文档里面有行没有注释掉,导致前后,报错!!!
    回复 有任何疑惑可以回复我~ 2018-10-13 17:07:52
Michael_PK 2018-10-13 10:32:33

先不要代码,先保证空的工程能正确编译先

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信