集成 vert.x 和 Spring MVC

integrate vert.x and Spring MVC

我在 vert.x 中有一个 运行 应用程序。我有很多缺失的功能,或者我只能说缺失 spring.

如何在 Tomcat 服务器上集成 vert.x 和 Spring MVC?

取决于您使用的 Vert.x 版本。 2.x 需要一个 mod 规则。像 mod-spring-appcontext。在 Vert.x 3.x 中,只需在代码中创建一个 Spring ApplicationContext,通常在应用程序的入口点,例如 public static void main 方法。我无法详细说明。 Vert.x 很少(如果有的话)问题会在这里引起注意。

使用 Vert.x 3 我认为您会想要使用 Vert.x Web 功能,如 here instead of Spring MVC if you want to give Vertx a go. It provides a different approach to developing a web application using the Multi-Reactor pattern than the traditional multi-threaded Servlet model which Spring MVC is based on. With the Servlet model every request runs on its own thread. In Vert.x there is an event loop that is single threaded. All requests are run on the same thread, which requires blocking I/O code to be written in special blocks (see Core Manual 所述)。

我不建议在 tomcat 容器上使用 vert.x,因为它们的理念完全不同。 Tomcat 是一个 servlet 容器,它为每个传入调用创建不同的线程,而 vert.x 在事件循环上工作。如果您缺少 spring 并且想使用它的 bean,您可以将它集成到 vert.x 环境中,并且 运行 worker verticles 中的任何阻塞代码。 你可以在这里看到一个例子:https://github.com/vert-x3/vertx-examples/tree/master/spring-examples/spring-example