The Spring boot inline container supports Tomcat, Jetty, Undertow. Why Choose Undertow.
Here is an article, time released on January 26, 2017:
Tomcat vs. Jetty vs. Undertow:comparison of Spring Boot Embedded Servlet Containers
This article provides a detailed test of the performance and memory usage of the Spring boot application under three containers, including complete test code and test flow. proves that the undertow is the best in performance and memory usage. use Undertow instead of Tomcat in spring boot
1. maven Example:
<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-undertow</ Artifactid>
</dependency>
2. Configuration Undertow,application.yml Example:
server.undertow.accesslog.dir= # undertow Access log directory.
Server.undertow.accesslog.enabled=false # Enable Access log.
Server.undertow.accesslog.pattern=common # Format pattern for access logs. Server.undertow.accesslog.prefix=access_log.
# Log file name prefix.
Server.undertow.accesslog.rotate=true # Enable Access log rotation.
Server.undertow.accesslog.suffix=log # log file name suffix.
server.undertow.buffer-size= # Size of each buffer in bytes.
server.undertow.buffers-per-region= # Number of buffer per region.
server.undertow.direct-buffers= # Allocate buffers outside the Java heap.
server.undertow.io-threads= # Number of I/O threads to create for the worker.
Server.undertow.max-http-post-size=0 # Maximum size in bytes of the HTTP post content. server.undertow.worker-threads= # Number of worker threads.
3. Use Undertow to monitor multiple port examples:
@Bean public Undertowembeddedservletcontainerfactory embeddedservletcontainerfactory () {
Undertowembeddedservletcontainerfactory factory = new Undertowembeddedservletcontainerfactory (); Factory.addbuildercustomizers (New Undertowbuildercustomizer () {@Override public void customize (Builder b
Uilder) {Builder.addhttplistener (8080, "0.0.0.0");
}
});
return factory; }