This project is a Spring Boot application for managing animals objects.
- Java 21 or later
- Maven
- Docker
- Postgres SQL Database
NOTE !!! Animals application requires a standalone Postgres DB. Make sure to run a postgres (container) with database application properties values when running Animals application via Intellij Idea or using script.
e. g. using default application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=jump
spring.datasource.password=soft
spring.datasource.driver-class-name=org.postgresql.Driver
spring.sql.init.platform=postgres
docker pull postgres
docker run --name postgres-container \
-e POSTGRES_USER=jump \
-e POSTGRES_PASSWORD=soft \
-e POSTGRES_DB=postgres \
-p 5432:5432 \
-d postgres
mvn clean install- Open IntelliJ IDEA.
- Click on
File->Openand select the project folder. - Wait for IntelliJ to import the project.
- Navigate to AnimalsApplication class in
Animals/src/main/java/org/jump/soft/animal/core. - Right-click on the class and choose
AnimalsApplication.
-
Open a terminal.
-
Navigate to the
Animalsdirectory in your project.cd /path/to/Animals/scripts -
Parameter -p stands for path to the project
./run_animals_app.sh -p <path/to/Animals>
example: ./run_animals_app.sh -p /home/branislavmalo
When you run your application with the docker-compose.yaml file, Docker will automatically pull the PostgreSQL image, set up the database, and configure everything for you, ensuring a seamless setup.
Ensure you are in the project's composefiles directory where the docker-compose.yml and Dockerfile are located.
docker-compose up --buildAccess the Application: Once the containers are up and running, Animals Spring Boot application will be accessible at:
http://localhost:8080
Stop the Containers: To stop the running containers, use:
docker-compose downTemplate HTTP requests for the endpoints are located in the postman_collection folder.
Creates the animal entity
curl --location --request POST 'http://localhost:8080/api/animals/add-animal' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Mufasa",
"age": 15,
"breedId": 1,
"gender": "MALE"
}'Removes the animal entity
curl --location --request DELETE 'http://localhost:8080/api/animals/remove-animal/{id}'Read the animal entity
curl --location --request GET 'http://localhost:8080/api/animals/get-animal/{id}'Update the animal entity
curl --location --request PUT 'http://localhost:8080/api/animals/update-animal/{id}' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": 1,
"name": "Ashara",
"age": 16,
"breedId": 3,
"gender": "FEMALE"
}'Read the animal entities
curl --location --request PUT 'http://localhost:8080/api/animals/get-animals' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": 1,
"name": "Ashara",
"age": 16,
"breedId": 3,
"gender": "FEMALE"
}'Read the animal entities with details
curl --location --request PUT 'http://localhost:8080/api/animals/get-animals-with-details' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": 1,
"name": "Ashara",
"age": 16,
"breedId": 3,
"gender": "FEMALE"
}'