How to configure Jetty in spring-boot (easily?)
Solution 1
There are some general extension points for servlet containers and also options for plugging Jetty API calls into those, so I assume everything you would want is in reach. General advice can be found in the docs. Jetty hasn't received as much attention yet so there may not be the same options available for declarative configuration as with Tomcat, and for sure it won't have been used much yet. If you would like to help change that, then help is welcome.
Solution 2
Possibility to configure Jetty (in parts) programatically from 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;
}
Elvin
Updated on June 12, 2021Comments
-
Elvin about 3 years
By following the tutorial, I could bring up the spring-boot with Jetty running using the following dependencies.
<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>
However, how could I configure the Jetty server such as:
- Server threads (Queue thread pool)
- Server connectors
- Https configurations.
- all those configuration available in Jetty...?
Is there an easy way to do in
- application.yml?
- Configuration class?
Any example would be greatly appreciated.
Many thanks!!
-
Elvin over 10 yearsThanks very much for your explanation!
-
JaskeyLam almost 8 years“Unable to start embedded container” after add that pom, would you please help to check stackoverflow.com/questions/39557018/…
-
Dave Syer almost 8 yearsWorks for me. Check the samples in spring boot.