PhoneBook application is an example project created as a Spring MVC (REST) application. The REST endpoints look as follows:
GET - receive all phoneBook records.
GET/{name} - all phones for the given name.
PUT/{name}; phoneNumber - add a phone to an existing name.
POST/; {“name”:”YourName”, “phoneNumber”: “+79998887711”} - create a new record in the phoneBook.
DELETE/{name} - removes record by name completely (including associated phone numbers).
Rest resources must be located under api/v1/contacts.
Uses JSON as a request/response body.
All records are kept in memory. It uses a mysql:5.7 docker database instance.
DELETE/{name} - throws an exception if there is no such phone in the PhoneBook. Exception is handled and the reason is printed out as a JSON object.
Java configuration is used in the App.
- Java version 17 ☕ -> openjdk 17.0.4 2022-07-19 LTS.
- Docker 🐳 -> get Docker Desktop.
- Postman. 🏣
- Maven.
- Intellij IDEA(optional).
- Execute command
dokcer compose up -d
. A docker mysql instance should spin up. A separate volume for persistent data will be created on Your local machine. Be sure that Yourport #3306
is not occupied. If so You need to edit thedocker-compose.yml
file 📁 in the ports section. - Execute command
mvn spring-boot:run
. The app will run and connect 🔌 to the mysql instance. - Open
http://localhost:7070/api/v1/contacts
- The browser will ask You for username and password since the endpoint is secured. 🔐
Below is the table with user credentials.
Username | Password | Role |
---|---|---|
john | fun123 | EMPLOYEE |
mary | fun123 | MANAGER |
susan | fun123 | ADMIN |
After login in. You should receive an empty array in response at the first run.
4. Use the provided Postman collection to add some users.