有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

springbootstarterwebflux和springbootstarterjetty之间的java冲突

我有一个微服务应用程序,在我包括

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

所以我可以用反应式。 在微服务工件中,我想使用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依赖项。 任何关于这个错误的想法以及如何克服它


共 (1) 个答案

  1. # 1 楼答案

    根据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>