Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 1.42 KB

File metadata and controls

30 lines (19 loc) · 1.42 KB

Vert.x Spring-vertx example project

This project is a demo of exposing Spring-hosted service beans (and therefore Spring-wired services) via vert.x verticles. In vert.x 3 it’s perfectly possible to share an application context between multiple verticles.

In this case the service bean we expose through vert.x is a trivial data access service running through Spring Data JPA (and using Hibernate). In effect we’re taking advantage of the ease of building data access via Spring/Hibernate but using vert.x as the connector between external clients and the Spring context.

Note that because we’re doing blocking JDBC access, we host the call to the service within an executeBlocking call, to avoid blocking the event bus.

You can run it directly in your IDE by creating a run configuration that uses the main class io.vertx.examples.spring.SpringExampleRunner.

The pom.xml uses the Maven shade plugin to assemble the application and all it’s dependencies into a single "fat" jar.

To build a "fat jar"

mvn package

To run the fat jar:

java -jar target/spring-example-3.9.0-fat.jar

(You can take that jar and run it anywhere there is a Java 8+ JDK. It contains all the dependencies it needs so you don’t need to install Vert.x on the target machine).

Now point your browser at http://localhost:8080 to see a simple welcome page, and then http://localhost:8080/products to see the Spring-hosted service invoked via the vertx eventbus