scala - SBT 依赖项中的 "container"和 "provided"有什么区别?

标签 scala sbt xsbt-web-plugin

阅读时build.sbt在许多 Web 应用程序中,经常可以看到标记为 "provided" 的依赖项。 ,见例如sbt-assembly documentation :

"org.apache.spark" %% "spark-core" % "0.8.0-incubating" % "provided"



我在 SBT 文档中找不到任何提及,但是 Maven documentation说以下关于提供:

  • provided

This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime



然而有时我也看到"container"在相同的位置,如 this build.sbt .这是同一件事吗?
val tomcatVersion = "7.0.53"

libraryDependencies ++= Seq(
  "org.apache.tomcat.embed" % "tomcat-embed-core"         % tomcatVersion % "container",
  "org.apache.tomcat.embed" % "tomcat-embed-logging-juli" % tomcatVersion % "container",
  "org.apache.tomcat.embed" % "tomcat-embed-jasper"       % tomcatVersion % "container",
  "org.apache.tomcat" % "tomcat-catalina" % tomcatVersion % "provided",
  "org.apache.tomcat" % "tomcat-coyote"   % tomcatVersion % "provided"
)

最佳答案

依赖项的第四个元素将依赖项与配置相关联;建立configuration dependency .它起源于 ivy , 其中 sbt内部使用。

“容器”配置定义为
xsbt-web-plugin version 0.9 ,将其带入您引用的项目 here .
它用于为 sbt container:start 建立容器/托管运行时.

顺便说一句 - 该运行时必须提供与“提供”配置相对应的运行时库,这些库在编译阶段使用,但不包含在生成的工件的传递依赖项中。

关于scala - SBT 依赖项中的 "container"和 "provided"有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40564464/

相关文章:

scala - sbt任务以增加项目版本

scala - SBT Web 插件 : Error getting ScopedKey(Scope(This, Select(ConfigKey(container)),This,This),full-classpath)

scala - sbt-web Assets 输出目录设置

scala - 从 Controller 中重构业务逻辑的好习惯方法

scala - 播放框架 : how to not watch a folder for changes in Play Framework

class - 如何在文档中引用实例方法?

scala - 如何使 sbt 任务使用特定的配置范围?

sbt - 设置一个键 local.sbt 以便在多项目中应用

scala - 如何让 sbt-assembly 合并正确?

scala - 自动在Scala/Lift/SBT .11中重新加载文件?