阅读时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/