gpt4 book ai didi

spring-boot - spring-boot-starter-web 和 spring-boot-starter-webflux 的区别?

转载 作者:行者123 更新时间:2023-12-04 12:39:32 36 4
gpt4 key购买 nike

我当时尝试包含上述依赖项之一,但找不到任何区别:

  • spring boot starter web:我可以看到 Flux 和 Mono 类并制作一个响应式(Reactive)休息 Controller
  • spring boot starter webflux:我可以看到rest Controller 类和注释,我可以制作一个规范的rest Controller

  • 那么,我错过了什么?使用 Spring Boot 2.2.5-RELEASE。

    最佳答案

    如果您查看官方文档,我认为有一小部分应该可以回答您的问题:
    1.1.4. Applicability

    Spring MVC or WebFlux?

    A natural question to ask but one that sets up an unsound dichotomy. Actually, both work together to expand the range of available options. The two are designed for continuity and consistency with each other, they are available side by side, and feedback from each side benefits both sides. The following diagram shows how the two relate, what they have in common, and what each supports uniquely:

    mvc and webflux venn


    您甚至可以同时添加两者,它将默认为常规 Spring MVC Web 应用程序,但允许您使用新的 WebClient在 Spring 5 中引入。在其他地方描述了这种行为, here :

    Both web frameworks mirror the names of their source modules (spring-webmvc and spring-webflux) and co-exist side by side in the Spring Framework. Each module is optional. Applications can use one or the other module or, in some cases, both — for example, Spring MVC controllers with the reactive WebClient.


    我不是这方面的专家,但和你一样,我很好奇两者的共同点及其背后的推理。您可以在这里找到更多信息:
  • Does not the starter-web and starter-webflux work together?
  • WebFlux web and webflux starter
  • 关于spring-boot - spring-boot-starter-web 和 spring-boot-starter-webflux 的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60787693/

    36 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com