Implement a Rest API in Java to support CRUD operations around a borrower for a Library. These are some scenarios:
- Search a list of borrowers
- Search a specific borrower with its full name
- Add a new borrower to a Library
- Validate a check data of the borrower details
- Update an existing borrower
- Delete an existing borrower
- etc ...
Create a Spring boot application with a migration tool such as Flyway to generate the schema and to insert the data to a Mysql database.
- Java 17
- Gradle 8.5
- WSL2/Ubuntu distro
- Install Docker, docker-compose in your distro.
- Set up your environment with the prerequisites and then clone the git project.
./gradlew clean build -x test
You can use this script to remove all old images generated by your project. If this is the first time you run the project, you don't require to run the script.
./reset.sh
docker-compose up -d --no-cache
As this is the first time you run the project, it will pull Mysql and build an image of the application. It will then run all services: db and app. (docker.compose.yml)
docker-compose ps
The log file is generated in the container and mapped with the local:
/logs/borrowers-services.log
If you have any issue, the previous command should show you that your service has stopped unexpectedly due to an issue.
Name Command State Ports
----------------------------------------------------------------------------------------------------------
c_bw_db docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp,:::3306->3306/tcp, 33060/tcp
c_bw_services ./entrypoint.sh Exit 1
In this case, check the log file above and try to troubleshoot the error.
docker-compose down
Any change in the code Java requires as usual to build your project. Make sure to run reset.sh which will remove all images. Then, you can start fresh again.
If you don't want to remove Mysql image, just do it manually yourself to remove the image of the app.
docker rmi mehdimik/borrowers:1.0.0-SNAPSHOT