Build Reactive Rest APIs with Spring WebFlux and Reactive MongoDB
1. Clone Repository
git clone https://github.com/lucaimbalzano/spring-reactive-mongodb
2. Build and run the app using maven
cd spring-reactive-mongodb$
mvn clean install -i
Alternatively, you can run the app without packaging it using -
mvn spring-boot:run
The server will start at http://localhost:8080.
The application defines following REST APIs
GET http://localhost:8090/api/person/allpeople - Get All people
POST http://localhost:8090/api/person/addperson - Create a new person
example JSON:
{
"firstname":"Mark",
"username": "Pistacchi",
"birth":"2022-02-11",
"age":34,
"addressDTO": {
"id": "620683b6798d2c8021d4f207",
"street": "Cordelia",
"streetNumber": "250",
"postalCode": 2341,
"city": "Guchang",
"countryCode": "CN"
}
}
PUT http://localhost:8090/api/person/updateperson/{id} - Update a person
DELETE http://localhost:8090/api/person/deleteperson/{id} - Delete a person
GET http://localhost:8090/api/address/getaddress/{id} - Retrieve an address by Id
GET http://localhost:8090/api/person/initDatabase - Initialize Database
You can use those Addresses to add some data on your DB in MongoDB.
Java - 11; Maven - 3.x.x; MongoDB - 3.x.x
The project also contains integration tests for all the Rest APIs.
For running the integration tests, go to the root directory of the project and type mvn test
in your terminal.