POC made in Java 21 to learn the setup and the basics of the reactive programming using Spring and PostgresQL.
In order to run this project you will need Docker and Java 17 - or higher.
In order to run this project the simpler way would be to make the following:
make run
This way you will start a container running the database and the app. Everything will start automatically.
To stop it, you can simply do the following:
make stop
localhost:8080/books
Body:
{
"isbn": "9781491936160",
"title": "Kafka: The Definitive Guide",
"publisher": "OReilly Media"
}
localhost:8080/books
localhost:8080/books/9781491936160
localhost:8080/books/publisher?name=OReilly Media
localhost:8080/books/title?title=JavaScript: The Good Parts
localhost:8080/books/contains?content=java
localhost:8080/books/9781491936160
- When talking about Spring Reactive you refer to
Mono<T>
as a Singular Object andFlux<T>
as a List of Objects. - Also, to have in mind when connecting to the database, the URL starts by r2dbc instead of jdbc. Example:
Reactive: r2dbc:postgresql://localhost:5432/database
Non-Reactive: jdbc:postgresql://localhost:5432/database
- When starting you Spring service, the ddl-auto property will not work. This means that even with class annotated with
@Table
your tables will not be created automatically. For this, you'll need a migration tool, like Flyway - The tool used in this project - or Liquibase. Here you have a link to see the difference between both.