Melad Basilius
Melad Basilius

Reputation: 4306

Conflict between spring-boot-starter-webflux and spring-boot-starter-jetty

I have a micro-service application, in one of the JAR dependencies i included the

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webflux</artifactId>
</dependency>

so i can use reactive. in the micro-service artifact i want to use jetty embedded server, so i included

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

Now i got this error

The Java/XML config for Spring MVC and Spring WebFlux cannot both be enabled, e.g. via @EnableWebMvc and @EnableWebFlux, in the same application.

Which i think is due to adding webflux and jetty dependencies. Any idea about this error and how to overcome it.

Upvotes: 2

Views: 7119

Answers (1)

Joe
Joe

Reputation: 588

According to the documentation this is possible via excluding netty:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-webflux</artifactId>
        <exclusions>
            <!-- Exclude the Netty dependency -->
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-reactor-netty</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- Use Jetty instead -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>

Upvotes: 4

Related Questions