spack2.4.5和scala2.11使用哪个版本的sbt和sbt程序集?

2skhul33  于 2021-05-27  发布在  Spark
关注(0)|答案(1)|浏览(495)

目前,在aws emr集群中,我使用的是spark v2.4.5 scala也有 v2.11 . 所以在我的项目中,我想使用scalav2.11和相应的 SBT 以及 Sbt-Assembly 版本。但我得到一个或另一个版本冲突的所有排列在各种博客和答案。
以下是引发错误的依赖项文件:
构建.sbt

name := "user-view-services"
version := "0.1"
scalaVersion := "2.11.12"
autoScalaLibrary := false

// Major Libraries version
val sparkVersion = "2.4.5"
val kafkaVersion = "2.5.0"
val akkaVersion = "2.6.4"

val confluentRepo = "confluent-repo" at "https://packages.confluent.io/maven/"

lazy val commonDependencies = Seq(
  "junit" % "junit" % "4.13" % Test,
  "org.mockito" % "mockito-all" % "1.10.19" % Test,
  "com.novocode" % "junit-interface" % "0.11" % Test,
  "ch.qos.logback" % "logback-classic" % "1.2.3",
  "com.typesafe" % "config" % "1.4.0",
  "com.opencsv" % "opencsv" % "5.1",
  "org.apache.avro" % "avro" % "1.9.2",
  "commons-beanutils" % "commons-beanutils" % "1.9.4",
  "commons-beanutils" % "commons-beanutils-bean-collections" % "1.8.3",
  "org.drools" % "drools-compiler" % "7.41.0.Final",
  "com.typesafe.scala-logging" % "scala-logging_2.11" % "3.5.0"
)

lazy val mongoDBDependencies = Seq(
  "org.mongodb" % "mongodb-driver-sync" % "4.0.2"
)

lazy val akkaDependencies = Seq(
  "com.typesafe.akka" %% "akka-actor-typed" % akkaVersion
)

lazy val kafkaDependencies = Seq(
  "org.apache.kafka" % "kafka-clients" % kafkaVersion,
  "org.apache.kafka" % "kafka-streams" % kafkaVersion,
  "io.confluent" % "kafka-avro-serializer" % "5.4.1"
)

lazy val sparkDependencies = Seq(
  "org.apache.spark" %% "spark-core" % sparkVersion,
  "org.apache.spark" %% "spark-sql" % sparkVersion,
  "org.apache.spark" %% "spark-streaming" % sparkVersion
)

lazy val rulemodule = (project in file("rule-module"))
  .enablePlugins(JavaAppPackaging)
  .settings(
    name := "rule-module",
    version := "1.0",
    libraryDependencies ++= commonDependencies
  )
/**
 * to create uberjar - run command
 * 1) sbt "sparkjobs / clean"
 * 2) sbt "sparkjobs / assembly"
 */
lazy val sparkjobs = (project in file("user-enrich-batch"))
  .dependsOn(rulemodule)
  .settings(
    name := "user-enrich-batch",
    version := "1.0",
    resolvers ++= Seq(
      confluentRepo
    ),
    libraryDependencies ++= commonDependencies,
    libraryDependencies ++= sparkDependencies,
    libraryDependencies ++= kafkaDependencies,
    dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-databind" % "2.6.7",
    assemblyMergeStrategy in assembly := {
      case PathList("META-INF", xs @ _*) => MergeStrategy.discard
      case x => MergeStrategy.first
    },
    mainClass in assembly := some("com.analytics.user.etl.ETLProcessor"),
    assemblyJarName := "user-view-batch-assembly.jar"
  )

lazy val userservice = (project in file("user-enrich-service"))
  .dependsOn(rulemodule)
  .enablePlugins(JavaAppPackaging)
  .settings(
    name := "user-enrich-service",
    version := "1.0",
    resolvers ++= Seq(
      confluentRepo
    ),
    libraryDependencies ++= commonDependencies,
    libraryDependencies ++= kafkaDependencies,
    libraryDependencies ++= akkaDependencies,
    libraryDependencies ++= mongoDBDependencies
  )

内部版本.属性

sbt.version = 0.13.17

插件.sbt

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.4")

scalaVersion := "2.11.12"

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")

addSbtPlugin("com.cavorite" % "sbt-avro-1-9" % "1.1.7")

装配.sbt

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")

错误:

[info] Loading global plugins from C:\Users\smishra5\.sbt\0.13\plugins
[info] Loading project definition from C:\dataanalytics\Recsys\project
[info] Updating {file:/C:/dataanalytics/Recsys/project/}recsys-build...
[info] Resolving com.eed3si9n#sbt-assembly;0.14.6 ...
[warn]  module not found: com.eed3si9n#sbt-assembly;0.14.6
[warn] ==== typesafe-ivy-releases: tried
[warn]   https://repo.typesafe.com/typesafe/ivy-releases/com.eed3si9n/sbt-assembly/scala_2.11/sbt_0.13/0.14.6/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn]   https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.eed3si9n/sbt-assembly/scala_2.11/sbt_0.13/0.14.6/ivys/ivy.xml
[warn] ==== local: tried
[warn]   C:\Users\smishra5\.ivy2\local\com.eed3si9n\sbt-assembly\scala_2.11\sbt_0.13\0.14.6\ivys\ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/com/eed3si9n/sbt-assembly_2.11_0.13/0.14.6/sbt-assembly-0.14.6.pom
[warn] ==== local-preloaded-ivy: tried
[warn]   C:\Users\smishra5\.sbt\preloaded\com.eed3si9n\sbt-assembly\0.14.6\ivys\ivy.xml
[warn] ==== local-preloaded: tried
[warn]   file:/C:/Users/smishra5/.sbt/preloaded/com/eed3si9n/sbt-assembly_2.11_0.13/0.14.6/sbt-assembly-0.14.6.pom
[info] Resolving com.typesafe.sbt#sbt-native-packager;1.3.4 ...
[warn]  module not found: com.typesafe.sbt#sbt-native-packager;1.3.4
[warn] ==== typesafe-ivy-releases: tried
[warn]   https://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbt/sbt-native-packager/scala_2.11/sbt_0.13/1.3.4/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn]   https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.typesafe.sbt/sbt-native-packager/scala_2.11/sbt_0.13/1.3.4/ivys/ivy.xml
[warn] ==== local: tried
[warn]   C:\Users\smishra5\.ivy2\local\com.typesafe.sbt\sbt-native-packager\scala_2.11\sbt_0.13\1.3.4\ivys\ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/com/typesafe/sbt/sbt-native-packager_2.11_0.13/1.3.4/sbt-native-packager-1.3.4.pom
[warn] ==== local-preloaded-ivy: tried
[warn]   C:\Users\smishra5\.sbt\preloaded\com.typesafe.sbt\sbt-native-packager\1.3.4\ivys\ivy.xml
[warn] ==== local-preloaded: tried
[warn]   file:/C:/Users/smishra5/.sbt/preloaded/com/typesafe/sbt/sbt-native-packager_2.11_0.13/1.3.4/sbt-native-packager-1.3.4.pom
[info] Resolving com.cavorite#sbt-avro-1-9;1.1.7 ...
[warn]  module not found: com.cavorite#sbt-avro-1-9;1.1.7
[warn] ==== typesafe-ivy-releases: tried
[warn]   https://repo.typesafe.com/typesafe/ivy-releases/com.cavorite/sbt-avro-1-9/scala_2.11/sbt_0.13/1.1.7/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn]   https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.cavorite/sbt-avro-1-9/scala_2.11/sbt_0.13/1.1.7/ivys/ivy.xml
[warn] ==== local: tried
[warn]   C:\Users\smishra5\.ivy2\local\com.cavorite\sbt-avro-1-9\scala_2.11\sbt_0.13\1.1.7\ivys\ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/com/cavorite/sbt-avro-1-9_2.11_0.13/1.1.7/sbt-avro-1-9-1.1.7.pom
[warn] ==== local-preloaded-ivy: tried
[warn]   C:\Users\smishra5\.sbt\preloaded\com.cavorite\sbt-avro-1-9\1.1.7\ivys\ivy.xml
[warn] ==== local-preloaded: tried
[warn]   file:/C:/Users/smishra5/.sbt/preloaded/com/cavorite/sbt-avro-1-9_2.11_0.13/1.1.7/sbt-avro-1-9-1.1.7.pom
[info] Resolving jline#jline;2.14.3 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.eed3si9n#sbt-assembly;0.14.6: not found
[warn]  :: com.typesafe.sbt#sbt-native-packager;1.3.4: not found
[warn]  :: com.cavorite#sbt-avro-1-9;1.1.7: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]          com.eed3si9n:sbt-assembly:0.14.6 (scalaVersion=2.11, sbtVersion=0.13)
[warn]          com.typesafe.sbt:sbt-native-packager:1.3.4 (scalaVersion=2.11, sbtVersion=0.13)
[warn]          com.cavorite:sbt-avro-1-9:1.1.7 (scalaVersion=2.11, sbtVersion=0.13)
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]          com.eed3si9n:sbt-assembly:0.14.6 (scalaVersion=2.11, sbtVersion=0.13) (C:\dataanalytics\Recsys\project\plugins.sbt#L5-6)
[warn]            +- default:recsys-build:0.1-SNAPSHOT (scalaVersion=2.11, sbtVersion=0.13)
[warn]          com.typesafe.sbt:sbt-native-packager:1.3.4 (scalaVersion=2.11, sbtVersion=0.13) (C:\dataanalytics\Recsys\project\plugins.sbt#L1-2)
[warn]            +- default:recsys-build:0.1-SNAPSHOT (scalaVersion=2.11, sbtVersion=0.13)
[warn]          com.cavorite:sbt-avro-1-9:1.1.7 (scalaVersion=2.11, sbtVersion=0.13) (C:\dataanalytics\Recsys\project\plugins.sbt#L7-8)
[warn]            +- default:recsys-build:0.1-SNAPSHOT (scalaVersion=2.11, sbtVersion=0.13)
sbt.ResolveException: unresolved dependency: com.eed3si9n#sbt-assembly;0.14.6: not found
unresolved dependency: com.typesafe.sbt#sbt-native-packager;1.3.4: not found
unresolved dependency: com.cavorite#sbt-avro-1-9;1.1.7: not found
        at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:320)
        at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:191)
        at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:168)
        at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
        at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
        at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:133)
        at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
        at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
        at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:95)
        at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:80)
        at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:99)
        at xsbt.boot.Using$.withResource(Using.scala:10)
        at xsbt.boot.Using$.apply(Using.scala:9)
        at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:60)
        at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:50)
        at xsbt.boot.Locks$.apply0(Locks.scala:31)
        at xsbt.boot.Locks$.apply(Locks.scala:28)
        at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
        at sbt.IvySbt.withIvy(Ivy.scala:128)
        at sbt.IvySbt.withIvy(Ivy.scala:125)
        at sbt.IvySbt$Module.withModule(Ivy.scala:156)
        at sbt.IvyActions$.updateEither(IvyActions.scala:168)
        at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1555)
        at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1551)
        at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$122.apply(Defaults.scala:1586)
        at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$122.apply(Defaults.scala:1584)
        at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
        at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1589)
        at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1583)
        at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
        at sbt.Classpaths$.cachedUpdate(Defaults.scala:1606)
        at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1533)
        at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1485)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
        at sbt.std.Transform$$anon$4.work(System.scala:63)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
        at sbt.Execute.work(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
[error] (*:update) sbt.ResolveException: unresolved dependency: com.eed3si9n#sbt-assembly;0.14.6: not found
[error] unresolved dependency: com.typesafe.sbt#sbt-native-packager;1.3.4: not found
[error] unresolved dependency: com.cavorite#sbt-avro-1-9;1.1.7: not found
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q

参考文献:https://github.com/sbt/sbt-assembly/issues/311

4c8rllxm

4c8rllxm1#

似乎您将sbt使用的scala版本和项目中使用的scala版本混为一谈。
如果您需要使用Scala2.11构建项目,只需在中指定即可 build.sbt ```
scalaVersion := "2.11.12"

你必须移除 `scalaVersion := "2.11.12"` 从 `plugins.sbt` 在 `project` 作为sbt的文件夹是用特定scala版本预先构建的,您不能更改它。例如, `0.13.17` 是用scala 2.10和sbt构建的 `1.x.x` 带scala `2.12` .
你可以自由使用任何你喜欢的sbt版本,但我建议使用最新的 `1.3.13` 以及相应插件的最新版本。

相关问题