This example shows how you can embed Vert.x in Spring Boot, having:
-
Spring container creating the verticles
-
a standard verticle with Vert.x web for the REST API
-
Spring backend services (with declarative transaction management and JPA repositories)
-
a worker verticle exposing the Spring services over the event bus through service proxies
This might be useful if you have an existing Spring codebase and want to keep your data access layer.
To try the example, execute this command in a terminal:
mvn clean spring-boot:run
Then add a book to the database:
curl http://localhost:8080/book --data '{"name": "The Practice of System and Network Administration", "author":"Thomas A. Limoncelli, Christina J. Hn, Strata R. Chalup"}'
You should now be able to see your book saved:
curl http://localhost:8080/books
Notice that the id
field is now set which means that the book as indeed been persisted in the database.