2013-12-08 43 views
26

通過遵循本教程,我可以使用以下依賴項運行帶有Jetty的spring-boot。如何在spring-boot中配置Jetty(很容易?)

<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> 

但是,我怎麼能配置Jetty服務器如:

  1. Server線程(隊列線程池)
  2. 服務器連接器
  3. 的Https的配置。
  4. Jetty中提供的所有配置...?

有沒有一種簡單的方法在

  1. application.yml辦?
  2. 配置類?

任何示例將不勝感激。

非常感謝!

回答

13

對於servlet容器有一些通用的擴展點,並且還有將Jetty API調用插入到這些擴展點的選項,所以我假定你想要的東西都可以觸及。一般建議可以找到in the docs。 Jetty尚未獲得足夠的關注,所以可能沒有像Tomcat一樣的可用於聲明性配置的選項,並且肯定它還沒有被使用太多。如果你想幫助改變這一點,那麼歡迎提供幫助。

+0

非常感謝您的解釋! – Elvin

+0

添加該pom後無法啓動嵌入的容器,請您幫助檢查http://stackoverflow.com/questions/39557018/unable-to-start-embedded-container-after-switch-from-tomcat-to -jetty-spring-bo – Jaskey

+0

適合我。檢查春季靴子中的樣品。 –

1

可能性如果有人使用Spring引導從http://howtodoinjava.com/spring/spring-boot/configure-jetty-server/

@Bean 
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() { 
    JettyEmbeddedServletContainerFactory jettyContainer = 
     new JettyEmbeddedServletContainerFactory(); 

    jettyContainer.setPort(9000); 
    jettyContainer.setContextPath("/home"); 
    return jettyContainer; 
} 
0

配置碼頭(零件)編程 - 你可以很容易地在你這個配置的application.properties正是如此:

server.max-http-post-size=n 

,其中n是您希望設置此屬性的最大大小。例如我使用:

server.max-http-post-size=5000000