为什么显示码头?

问题描述 投票:0回答:1

我已经用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/下载Jetty服务器?

通常,war文件必须放入webapps filder中:

enter image description here

java scala jetty http4s
1个回答
0
投票

[如果您查看http4s的build.sbt,您会看到许多http4s库使用Jetty作为基础实现。例如,您最有可能使用的build.sbt

因此,您不必下载码头或任何其他容器。如果您想使代码需要一个容器,则很可能需要付出一些额外的努力。

© www.soinside.com 2019 - 2024. All rights reserved.