java - spring-boot-starter-webflux 和 spring-boot-starter-jetty 之间的冲突

标签 java spring rx-java spring-webflux

我有一个微服务应用程序,在我包含的 JAR 依赖项之一中

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

所以我可以使用响应式(Reactive)。 在微服务 Artifact 中我想使用jetty嵌入式服务器,所以我包含了

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

现在我遇到了这个错误

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

我认为这是由于添加了 webflux 和 jetty 依赖项。 关于此错误以及如何克服它的任何想法。

最佳答案

根据documentation这可以通过排除 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>

关于java - spring-boot-starter-webflux 和 spring-boot-starter-jetty 之间的冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57851528/

相关文章:

java - org.tuckey.web.filters.urlrewrite 和 tomcat 5.5 的问题

java - 卡在 ControllerLinkBuilder 上

json - Spring Boot : Return a empty JSON instead of empty body when returned object is null

android - map 中的翻新+ RX错误处理

java - 如何为多个观察者实现不同的行为?

java - 使用java解析json数据

java - AsyncTask 完成后全局变量返回 0.0

java - 使用 Android SAXParser,我的 XML 元素神秘地分成两半

java - Struts2 仅针对特定类型引发类型转换错误

java - 如何在 RxJava 2 中使用 Flowable?