Spring Boot 3 OpenApi 3 with TomcatReactiveWebServerFactory

102 Views Asked by At

Running Spring Boot 3.0.4 with OpenApi 2.2

I have a number of services running with this configuration

        <!-- Starts tomcat access to actuator endpoints -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- Starts netty -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
            <version>2.2.0</version>
        </dependency>

Most of the service start using the TomcatServletWebServerFactory and I am able to hit the Swagger UI and the specification endpoints

However, I have one service that starts using the TomcatReactiveWebServerFactory. This one won't server the Swagger UI. I noticed in the logs that the context was not being set, therefore I implemented:

@Configuration
public class TomcatReactiveConfig extends TomcatReactiveWebServerFactory {

    @Value("${server.servlet.context-path}")
    private String contextPath;

    @Override
    protected void configureContext(final Context context) {
        super.configureContext(context);
        if (StringUtils.isNotBlank(this.contextPath)) {
            context.setPath(this.contextPath);
        }
    }

While this gave me a context-path, it didn't solve the Swagger UI issue.

My question is what determines which Tomcat Factory is being used? I didn't even know there was a Reactive Tomcat?

Which dependency can I exclude it from?

0

There are 0 best solutions below