Intro: Spring Boot Version: 3.4.4 Java Version: 23 Tomcat Servlet Container has been the default & preferred server in my application from the beginning.
Problem: Some auto-configuration classes are defined as static inner classes inside top-level configs (e.g., EmbeddedWebServerFactoryCustomizerAutoConfiguration$UndertowWebServerFactoryCustomizerConfiguration). These are conditionally loaded based on classpath presence (e.g. Undertow.class).
Here's the excerpt for convenience:
import io.undertow.Undertow;
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ Undertow.class, SslClientAuthMode.class })
public static class UndertowWebServerFactoryCustomizerConfiguration {
@Bean
public UndertowWebServerFactoryCustomizer undertowWebServerFactoryCustomizer(Environment environment,
ServerProperties serverProperties) {
return new UndertowWebServerFactoryCustomizer(environment, serverProperties);
}
@Bean
@ConditionalOnThreading(Threading.VIRTUAL)
UndertowDeploymentInfoCustomizer virtualThreadsUndertowDeploymentInfoCustomizer() {
return (deploymentInfo) -> deploymentInfo.setExecutor(new VirtualThreadTaskExecutor("undertow-"));
}
}
Here is the maven dependency that includes io.undertow.Undertow
.
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-core</artifactId>
<version>2.3.18.Final</version>
</dependency>
However, since these inner config classes are not registered in AutoConfiguration.imports, they cannot be excluded via spring.autoconfigure.exclude.
This creates a situation where:
- I need to use Undertow manually in an isolated use case (non-servlet container)
- I do not want Spring Boot to auto-configure anything related to Undertow, especially not an additional Servlet Container
- But Spring Boot sees Undertow.class and tries to auto-configure the factory anyway
- I cannot exclude just the inner config class, and excluding the top-level class disables unrelated embedded server support like Tomcat.
Expected: Support spring.autoconfigure.exclude for inner config classes or provide a mechanism to opt-out of specific servlet container support (like server.exclude=undertow).
I am aware that there is/was a similar ask with issue number #5427 which was declined as it was deemed "not reasonable" and to quote @philwebb :
We can't easily disable inner-configurations. I'd rather take each need on a case-by-case basis and work out why a specific inner-configuration couldn't be used.
I kindly request this requirement to be reconsidered as it has been 9 years over the other issue and I can't really come up with an elegant solution.