将 Intellij 与 SBT 一起使用时如何更改提供的依赖项?
How to change Provided dependencies when using Intellij with SBT?
我的 build.sbt 看起来像这样:
libraryDependencies ++= Seq(
"org.apache.hadoop" % "hadoop-aws" % sparkVersion % Provided,
"org.apache.spark" %% "spark-core" % sparkVersion % Provided,
"org.apache.spark" %% "spark-sql" % sparkVersion % Provided,
"org.scala-lang" % "scala-library" % scalaVersion.value % Provided
)
虽然 运行 我的 Intellij 应用程序出现 NoClassDefFoundError
异常,因为它找不到 spark 库。所以在使用Intellij的时候,我需要:
libraryDependencies ++= Seq(
"org.apache.hadoop" % "hadoop-aws" % sparkVersion,
"org.apache.spark" %% "spark-core" % sparkVersion,
"org.apache.spark" %% "spark-sql" % sparkVersion,
"org.scala-lang" % "scala-library" % scalaVersion.value % Provided
)
但这导致最终的扁平罐子非常大。
如何根据是否使用 Intellij 来获得不同的 Provided 依赖项列表?
我的用例的解决方案是检查 IntelliJ Add dependencies with "provided" scope to classpath
选项。在这里找到它:
How to work efficiently with SBT, Spark and "provided" dependencies?
由于UI已经改变,这里是Intellij 2021.2.3的截图:
选择后,您应该会看到:
我的 build.sbt 看起来像这样:
libraryDependencies ++= Seq(
"org.apache.hadoop" % "hadoop-aws" % sparkVersion % Provided,
"org.apache.spark" %% "spark-core" % sparkVersion % Provided,
"org.apache.spark" %% "spark-sql" % sparkVersion % Provided,
"org.scala-lang" % "scala-library" % scalaVersion.value % Provided
)
虽然 运行 我的 Intellij 应用程序出现 NoClassDefFoundError
异常,因为它找不到 spark 库。所以在使用Intellij的时候,我需要:
libraryDependencies ++= Seq(
"org.apache.hadoop" % "hadoop-aws" % sparkVersion,
"org.apache.spark" %% "spark-core" % sparkVersion,
"org.apache.spark" %% "spark-sql" % sparkVersion,
"org.scala-lang" % "scala-library" % scalaVersion.value % Provided
)
但这导致最终的扁平罐子非常大。
如何根据是否使用 Intellij 来获得不同的 Provided 依赖项列表?
我的用例的解决方案是检查 IntelliJ Add dependencies with "provided" scope to classpath
选项。在这里找到它:
How to work efficiently with SBT, Spark and "provided" dependencies?
由于UI已经改变,这里是Intellij 2021.2.3的截图:
选择后,您应该会看到: