sbt 包运行但不构建 jar 文件

sbt package runing but don't build a jar file

** 我想构建一个 spark streaming kafka 应用程序,它将使用来自 kafka 主题的数据。但是当我执行 sbt 运行 时,没有问题,即使是 sbt 包但没有创建 jar 文件。有人能帮我吗?我正在使用 IntelliJ IDE **

this is my build.sbt

`name := "untitled4"

version := "0.1"

scalaVersion := "2.12.10"
autoScalaLibrary := false


// https://mvnrepository.com/artifact/org.apache.spark/spark-streaming
libraryDependencies += "org.apache.spark" %% "spark-streaming" % "3.0.2"

// https://mvnrepository.com/artifact/org.apache.spark/spark-streaming-kafka-0-10
libraryDependencies += "org.apache.spark" %% "spark-streaming-kafka-0-10" % "3.0.2"

// https://mvnrepository.com/artifact/org.apache.spark/spark-core
libraryDependencies += "org.apache.spark" %% "spark-core" % "3.0.2"

// https://mvnrepository.com/artifact/org.apache.spark/spark-sql
libraryDependencies += "org.apache.spark" %% "spark-sql" % "3.0.2

当我 运行 sbt 包时: 这是 sbt 包的输出。

 C:\Users\IdeaProjects\untitled4>sbt package
[info] welcome to sbt 1.4.7 (Oracle Corporation Java 1.8.0_281)
[info] loading global plugins from C:\.sbt.0\plugins
[info] loading project definition from C:\Users\IdeaProjects\untitled4\project
[info] loading settings for project untitled4 from build.sbt ...
[info] set current project to untitled4 (in build file:/C:/Users/IdeaProjects/untitled4/)
[success] Total time: 1 s, completed 27 mai 2021 11:21:41

问题不是很清楚。你是说你可以 运行 来自 IntelliJ 的应用程序,但不能生成一个 jar 来部署到服务器?由于 sbt package 的输出没有谈论 packaginjg,我猜测它已经构建并缓存了。

  1. jar/s 是否不存在于 /C:/Users/IdeaProjects/untitled4/ 中?是空的吗?
  2. 你能试试 运行ning sbt clean compile package 并再次检查文件夹吗?

此外,请注意,这将为所有依赖项创建多个 jar 文件。如果您需要单个 uber-jar 进行部署,您可以 运行 sbt assembly