<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Spring Boot – 配置 Jetty 服務器 > 原文: [https://howtodoinjava.com/spring-boot/configure-jetty-server/](https://howtodoinjava.com/spring-boot/configure-jetty-server/) 默認情況下,Spring Boot 使用嵌入式 tomcat 服務器來運行應用程序。 有時,您可能需要使用 [Jetty](https://www.eclipse.org/jetty/) 服務器來代替 tomcat 服務器。 Spring Boot 將 Tomcat 和 Jetty 依賴項捆綁在一起,作為單獨的啟動器,以幫助簡化此過程。 您可以通過以下簡單步驟使用 Jetty。 ## 添加`spring-boot-starter-jetty`依賴 您將需要更新`pom.xml`并添加對`spring-boot-starter-jetty`的依賴。 另外,您將需要排除默認添加的`spring-boot-starter-tomcat`依賴。 ```java <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId> </dependency> ``` 在 gradle 中,可以通過以下方式實現有效的更改: ```java configurations { compile.exclude module: "spring-boot-starter-tomcat" } dependencies { compile("org.springframework.boot:spring-boot-starter-web:2.0.0.BUILD-SNAPSHOT") compile("org.springframework.boot:spring-boot-starter-jetty:2.0.0.BUILD-SNAPSHOT") } ``` ## 配置 Jetty 選項 要覆蓋,默認 Jetty 運行時配置 – 您可以在`application.properties`文件中對其進行配置。 `application.properties` ```java server.port=8080 server.servlet.context-path=/home ####Jetty specific properties######## server.jetty.acceptors= # Number of acceptor threads to use. server.jetty.max-http-post-size=0 # Maximum size in bytes of the HTTP post or put content. server.jetty.selectors= # Number of selector threads to use. ``` 另外,您可以使用`JettyEmbeddedServletContainerFactory` bean 以編程方式配置這些選項。 ```java @Bean public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() { JettyEmbeddedServletContainerFactory jettyContainer = new JettyEmbeddedServletContainerFactory(); jettyContainer.setPort(9000); jettyContainer.setContextPath("/home"); return jettyContainer; } ``` #### Spring Boot 2.0.0.RELEASE 的更新 上面的代碼段對 spring boot spanshot 版本有效。 在 Spring boot `2.0.0.RELEASE`可用之后,您將使用[`ConfigurableServletWebServerFactory`](https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/web/servlet/server/ConfigurableServletWebServerFactory.html)和[`JettyServletWebServerFactory`](https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.html)類。 `Create bean of type ConfigurableServletWebServerFactory` ```java @Bean public ConfigurableServletWebServerFactory webServerFactory() { JettyServletWebServerFactory factory = new JettyServletWebServerFactory(); factory.setPort(9000); factory.setContextPath("/myapp"); factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/notfound.html")); return factory; } ``` 將您的問題留給我,有關在任何 spring boot 應用程序中使用 jetty 代替 tomcat 服務器的問題。 學習愉快! 參考:[配置 Jetty](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-use-another-web-server)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看