SBT 依赖关系中 "container" 和 "provided" 有什么区别?
What is the difference between "container" and "provided" in SBT dependencies?
在阅读 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. It originates with ivy,sbt
在内部使用。
"container" 配置 定义为
xsbt-web-plugin
version 0.9, which is brought into the project you reference here。
它用于为 sbt container:start
.
建立 container/hosting 运行时
顺便说一句 - 运行时必须提供与 "provided" 配置 相对应的运行时库,这些库在编译阶段使用但不包含在传递中生成的工件的依赖关系。
在阅读 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. It originates with ivy,sbt
在内部使用。
"container" 配置 定义为
xsbt-web-plugin
version 0.9, which is brought into the project you reference here。
它用于为 sbt container:start
.
顺便说一句 - 运行时必须提供与 "provided" 配置 相对应的运行时库,这些库在编译阶段使用但不包含在传递中生成的工件的依赖关系。