我有一个微服务应用程序,在我包含的 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/