SBT组装需要很长时间才能在IntelliJ中构建jar

时间:2018-05-26 13:17:35

标签: intellij-idea sbt sbt-assembly

我的build.sbt看起来像这样:

libraryDependencies ++= Seq(
  "org.apache.spark" %% "spark-core" % "2.2.0",
  "org.apache.spark" %% "spark-streaming_2.11" % "2.2.0",
  "org.apache.spark" %% "spark-sql" % "2.2.0",
  "org.apache.spark" %% "spark-hive" % "2.2.0",
  "org.apache.spark" %% "spark-sql-kafka-0-10" % "2.2.0",
  "org.apache.kafka" %% "kafka-clients" % "0.10.2.1",
  "com.typesafe.scala-logging" %% "scala-logging-slf4j" % "2.1.2",
  "org.apache.spark" %% "spark-streaming-kafka-0-10" % "2.2.0",
  "com.typesafe.akka" %% "akka-actor" % "2.5.2"
).map(_.exclude("org.slf4j", "log4j-over-slf4j"))
assemblyMergeStrategy in assembly := {
  case PathList("META-INF", xs @ _*) => MergeStrategy.discard
  case x => MergeStrategy.first
}
assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false)
assemblyOption in assembly := (assemblyOption in assembly).value.copy(cacheUnzip = false)

运行sbt程序集时,需要花费更长的时间并且还会抛出Java Heap Space错误。

上面的build.sbt需要添加什么?

先谢谢!!

1 个答案:

答案 0 :(得分:0)

您可以尝试通过在项目的根目录中创建以下.jvmopts文件来增加Java堆内存:

-Xmx1G 
-XX:MaxMetaspaceSize=1G

下次运行sbt时,应该选择这些设置。