Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在spring boot中配置Jetty(很容易?)_Jetty_Spring Boot - Fatal编程技术网

如何在spring boot中配置Jetty(很容易?)

如何在spring boot中配置Jetty(很容易?),jetty,spring-boot,Jetty,Spring Boot,通过遵循本教程,我可以使用以下依赖项启动运行Jetty的spring引导 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion>

通过遵循本教程,我可以使用以下依赖项启动运行Jetty的spring引导

    <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-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>

org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧启动机tomcat
org.springframework.boot
弹簧靴起动器执行器
org.springframework.boot
弹簧靴起动器码头
但是,如何配置Jetty服务器,例如:

  • 服务器线程(队列线程池)
  • 服务器连接器
  • Https配置
  • 码头上的所有配置
  • 有没有一个简单的方法可以做到这一点

  • application.yml
  • 配置类 任何例子都将不胜感激


    非常感谢

    servlet容器有一些通用扩展点,也有将Jetty API调用插入这些容器的选项,所以我假设您想要的一切都可以实现。可以找到一般建议。Jetty还没有得到足够的重视,因此可能没有与Tomcat相同的声明性配置选项,当然它也不会被广泛使用。如果您想帮助更改,那么欢迎提供帮助。

    可以从


    如果有人在使用Spring Boot,您可以在应用程序中轻松配置它。因此,属性:

    server.max-http-post-size=n
    
    其中n是要设置此属性的最大大小。例如,我使用:

    server.max-http-post-size=5000000
    

    到2020年,在开发新版本时,您需要这样做,以配置Jetty端口、上下文路径和线程池属性。我在Spring Boot版本2.1.6上测试了这一点,而我提到的文档是针对版本2.3.3的

    在配置文件中创建服务器工厂bean

    @Bean public ConfigurableServletWebServerFactory webServerFactory() { JettyServletWebServerFactory factory = new JettyServletWebServerFactory(); factory.setPort(8080); factory.setContextPath("/my-app"); QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMinThreads(10); threadPool.setMaxThreads(100); threadPool.setIdleTimeout(60000); factory.setThreadPool(threadPool); return factory; } @豆子 公共可配置ServletWebServerFactory webServerFactory(){ JettyServletWebServerFactory=新的JettyServletWebServerFactory(); 工厂设置端口(8080); setContextPath(“/my app”); QueuedThreadPool threadPool=新的QueuedThreadPool(); threadPool.setMinThreads(10); 线程池。setMaxThreads(100); threadPool.setIdleTimeout(60000); factory.setThreadPool(线程池); 返回工厂; } 以下是Spring文档的链接:

    Spring Boot通过属性文件提供以下特定配置:-

    服务器:
    码头:
    连接空闲超时:#连接关闭前可以空闲的时间。
    最大http表单post大小:#任何http post请求中表单内容的最大大小,例如200000B
    访问日志:
    启用:#启用访问日志,例如true
    附加:#启用附加到日志,例如true
    自定义格式:#自定义日志格式
    文件日期格式:#要放置在日志文件名中的日期格式
    文件名:#日志文件名,如果未指定,日志将重定向到“System.err”
    格式:#日志格式,如ncsa
    忽略路径:#请求不应记录的路径
    保留期:#删除轮换日志文件前的天数,例如31天
    线程:
    接受程序:#要使用的接受程序线程数。默认值为-1时,接受程序的数量从操作环境中派生。
    选择器:#要使用的选择器线程数。默认值为-1时,选择器的数量从操作环境派生。
    最小值:#最小螺纹数,如8
    最大:最大螺纹数,如200
    最大队列容量:#线程池支持队列的最大容量。根据线程配置计算默认值。
    空闲超时:#以毫秒为单位的最大线程空闲时间,例如60000ms
    

    有关更多配置详细信息,请参阅官方Spring Boot。

    非常感谢您的解释!“无法启动嵌入式容器”添加pom后,请帮我检查工作。检查弹簧靴中的样品。 @Bean public ConfigurableServletWebServerFactory webServerFactory() { JettyServletWebServerFactory factory = new JettyServletWebServerFactory(); factory.setPort(8080); factory.setContextPath("/my-app"); QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMinThreads(10); threadPool.setMaxThreads(100); threadPool.setIdleTimeout(60000); factory.setThreadPool(threadPool); return factory; }