Problem
I am in the process of upgrading a spring webflux application from Spring Boot 3 to Spring Boot 4. After upgrading, I encounter the following error at startup:
Web application could not be started as there was no org.springframework.boot.web.server.reactive.ReactiveWebServerFactory bean defined in the context.
I was able to create a minimally reproducible example.
Main Application / parent class:
@SpringBootApplication
public class ApplicationConfig {
public static void main(String[] args) {
new SpringApplicationBuilder()
.parent(ApplicationConfig.class).web(WebApplicationType.NONE)
.child(ChildConfig.class).web(WebApplicationType.REACTIVE).main(ChildConfig.class)
.run(args);
}
}
Child config class:
@Configuration
@EnableAutoConfiguration
public class ChildConfig {
}
Fix
I was able to fix this by excluding the auto-configuration for the web server in the parent config, like so:
@SpringBootApplication(exclude = {NettyReactiveWebServerAutoConfiguration.class})
This is just a temporary workaround, however. In Spring Boot 3, ReactiveWebServerFactoryAutoConfiguration used @ConditionalOnWebApplication(type = Type.REACTIVE). I believe this annotation should be reintroduced for Spring Boot 4's NettyReactiveWebServerAutoConfiguration
Problem
I am in the process of upgrading a spring webflux application from Spring Boot 3 to Spring Boot 4. After upgrading, I encounter the following error at startup:
I was able to create a minimally reproducible example.
Main Application / parent class:
Child config class:
Fix
I was able to fix this by excluding the auto-configuration for the web server in the parent config, like so:
@SpringBootApplication(exclude = {NettyReactiveWebServerAutoConfiguration.class})This is just a temporary workaround, however. In Spring Boot 3, ReactiveWebServerFactoryAutoConfiguration used
@ConditionalOnWebApplication(type = Type.REACTIVE). I believe this annotation should be reintroduced for Spring Boot 4's NettyReactiveWebServerAutoConfiguration