为什么显示Jetty?
Why does it show Jetty?
我已经使用 https://http4s.org/:
构建了我的网络应用程序
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/ 下载 Jetty 服务器?
通常,war 文件必须放入 webapps 文件夹中:
如果您查看最有可能使用的 build.sbt
of http4s you'll see that many of http4s libraries use Jetty as the underlying implementation. For instance http4s-jetty。
所以不,您不必下载码头或任何其他容器。如果你想让你的代码需要一个容器,你很可能需要付出一些额外的努力。
我已经使用 https://http4s.org/:
构建了我的网络应用程序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/ 下载 Jetty 服务器?
通常,war 文件必须放入 webapps 文件夹中:
如果您查看最有可能使用的 build.sbt
of http4s you'll see that many of http4s libraries use Jetty as the underlying implementation. For instance http4s-jetty。
所以不,您不必下载码头或任何其他容器。如果你想让你的代码需要一个容器,你很可能需要付出一些额外的努力。