【问题标题】:sbt - object apache is not a member of package orgsbt - 对象 apache 不是包 org 的成员
【发布时间】:2019-04-27 04:28:31
【问题描述】:

我想使用 sbt 部署和提交一个 spark 程序,但是它抛出错误。

代码:

package in.goai.spark

import org.apache.spark.{SparkContext, SparkConf}

object SparkMeApp {
  def main(args: Array[String]) {
    val conf = new SparkConf().setAppName("First Spark")
    val sc = new SparkContext(conf)
    val fileName = args(0)
    val lines = sc.textFile(fileName).cache
    val c = lines.count
    println(s"There are $c lines in $fileName")
  }
}

build.sbt

    name := "First Spark"

    version := "1.0"

    organization := "in.goai"

    scalaVersion := "2.11.8"

    libraryDependencies += "org.apache.spark" %% "spark-core" % "1.6.1"

    resolvers += Resolver.mavenLocal

first/project目录下

build.properties

bt.version=0.13.9

当我尝试运行 sbt package 时,它的抛出错误如下所示。

[root@hadoop first]# sbt package
[info] Loading project definition from /home/training/workspace_spark/first/project
[info] Set current project to First Spark (in build file:/home/training/workspace_spark/first/)
[info] Compiling 1 Scala source to /home/training/workspace_spark/first/target/scala-2.11/classes...
[error] /home/training/workspace_spark/first/src/main/scala/LineCount.scala:3: object apache is not a member of package org
[error] import org.apache.spark.{SparkContext, SparkConf}
[error]            ^
[error] /home/training/workspace_spark/first/src/main/scala/LineCount.scala:9: not found: type SparkConf
[error]      val conf = new SparkConf().setAppName("First Spark")
[error]                     ^
[error] /home/training/workspace_spark/first/src/main/scala/LineCount.scala:11: not found: type SparkContext
[error]      val sc = new SparkContext(conf)
[error]                   ^
[error] three errors found
[error] (compile:compile) Compilation failed
[error] Total time: 4 s, completed May 10, 2018 4:05:10 PM

我也尝试过使用extendsApp,但没有任何变化。

【问题讨论】:

  • 试试sbt clean package

标签: scala apache-spark sbt


【解决方案1】:

请从build.sbt 中删除resolvers += Resolver.mavenLocal。由于 spark-core 在 Maven 上可用,我们不需要使用本地解析器。

之后,你可以试试sbt clean package

【讨论】:

猜你喜欢
  • 2020-04-20
  • 1970-01-01
  • 1970-01-01
  • 2012-12-20
  • 2016-02-29
  • 2019-11-22
  • 1970-01-01
  • 2016-05-31
  • 2016-02-09
相关资源
最近更新 更多