[英]Why does it show Jetty?
我已经用https://http4s.org/构建了我的 web 应用程序:
object UserSvcServer {
def stream[F[_]: ConcurrentEffect](implicit T: Timer[F], C: ContextShift[F]): Stream[F, Nothing] = {
val helloWorldAlg = HelloWorld.impl[F]
val httpApp = (
UserSvcRoutes.helloWorldRoutes[F](helloWorldAlg)
).orNotFound
val finalHttpApp = Logger.httpApp(true, true)(httpApp)
for {
exitCode <- JettyBuilder[F]
.bindHttp(8080, "0.0.0.0")
.mountHttpApp(finalHttpApp, "/")
.serve
} yield exitCode
}.drain
}
正如您在上面的代码中看到的,它使用JettyBuilder
。
当我启动应用程序时,日志显示:
[main] INFO o.e.j.util.log - Logging initialized @730ms to org.eclipse.jetty.util.log.Slf4jLog
[ioapp-compute-0] INFO o.e.j.s.Server - jetty-9.4.28.v20200408; built: 2020-04-08T17:49:39.557Z; git: ab228fde9e55e9164c738d7fa121f8ac5acd51c9; jvm 11.0.7+10-LTS
[ioapp-compute-0] INFO o.h.s.Http4sServlet - Detected Servlet API version 3.1
[ioapp-compute-0] INFO o.h.s.Http4sServlet - Using non-blocking servlet I/O with chunk size 4096
[ioapp-compute-0] INFO o.e.j.s.h.ContextHandler - Started o.e.j.s.ServletContextHandler@71cc4a24{/,null,AVAILABLE}
这是否意味着 web 应用程序已经在 Jetty 上运行,我不必从https://www.eclipse.org/jetty下载码头服务器?
通常,war 文件必须放入 webapps 文件中:
如果您查看build.sbt
的 build.sbt,您会发现许多 http4s 库都使用 Jetty 作为底层实现。 例如您最有可能使用的 http4s-jetty 。
所以不,您不必下载码头或任何其他容器。 如果你想让你的代码需要一个容器,你很可能需要付出一些额外的努力。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.