https://github.com/vivek-dhamanemath/spring-boot-actordb
The ActorDB project is a Spring Boot application designed to manage actor information. It includes functionalities to add, update, delete, and retrieve actor details. The project is structured into several packages, each with its specific responsibilities.
https://github.com/vivek-dhamanemath/spring-boot-actordb
java17-spring-boot maven mysql-database postman restful-webservices spring-boot springdata-jpa
Last synced: about 2 months ago
JSON representation
The ActorDB project is a Spring Boot application designed to manage actor information. It includes functionalities to add, update, delete, and retrieve actor details. The project is structured into several packages, each with its specific responsibilities.
- Host: GitHub
- URL: https://github.com/vivek-dhamanemath/spring-boot-actordb
- Owner: vivek-dhamanemath
- Created: 2025-01-21T13:27:31.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2025-01-28T13:44:11.000Z (3 months ago)
- Last Synced: 2025-01-28T14:38:50.521Z (3 months ago)
- Topics: java17-spring-boot, maven, mysql-database, postman, restful-webservices, spring-boot, springdata-jpa
- Language: Java
- Homepage:
- Size: 35.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SpringBoot ActorDB Project
## Overview
The ActorDB project is a Spring Boot application designed to manage actor information. It includes functionalities to add, update, delete, and retrieve actor details. The project is structured into several packages, each with its specific responsibilities.## Packages
### 1. `com.jsp.springboot.actor`
This is the root package of the application. It contains the main class that bootstraps the Spring Boot application.- **SpringBootActorApplication.java**: The entry point of the Spring Boot application. It contains the `main` method which starts the application.
### 2. `com.jsp.springboot.actor.controller`
This package contains the REST controllers that handle HTTP requests and responses.- **ActorController.java**: This controller provides endpoints to manage actor entities. It includes methods to add, update, delete, and retrieve actors.
### 3. `com.jsp.springboot.actor.entity`
This package contains the entity classes that represent the database tables.- **Actor.java**: This is the entity class for the actor table. It includes fields like `actorId`, `actorName`, `age`, `industry`, and `nationality`.
### 4. `com.jsp.springboot.actor.repository`
This package contains the repository interfaces that provide CRUD operations for the entities.- **ActorRepository.java**: This interface extends `JpaRepository` and provides methods to perform CRUD operations on the actor entity.
### 5. `com.jsp.springboot.actor.service`
This package contains the service classes that implement the business logic.- **ActorService.java**: This service class contains the business logic for managing actors. It uses the `ActorRepository` to perform CRUD operations.
## Running the Application
To run the application, execute the `main` method in the `SpringBootActorApplication` class. This will start the embedded server and deploy the application.```java
public static void main(String[] args) {
SpringApplication.run(SpringBootActorApplication.class, args);
}
```## Endpoints
The application exposes the following REST endpoints:- `POST /actors`: Add a new actor
- `GET /actors`: Retrieve all actors
- `GET /actors/{id}`: Retrieve an actor by ID
- `PUT /actors/{id}`: Update an actor by ID
- `DELETE /actors/{id}`: Delete an actor by ID## RESTful Web Service/API
The application follows RESTful design principles to provide a scalable and maintainable API. Each endpoint corresponds to a specific operation on the actor resource, and the HTTP methods (POST, GET, PUT, DELETE) are used to perform these operations. The API is designed to be stateless, meaning each request from a client contains all the information needed to process the request.### Key Features of the RESTful API:
- **Resource-Based**: The API is centered around the actor resource.
- **Stateless**: Each request is independent and contains all necessary information.
- **Uniform Interface**: The API uses standard HTTP methods and status codes.
- **Client-Server Architecture**: The client and server are separate, allowing for independent development and scaling.## Testing with Postman
Postman is a popular tool for testing REST APIs. You can use Postman to test the endpoints provided by this application.1. **Add a new actor**
- Method: POST
- URL: `http://localhost:8080/actors`
- Body:
```json
{
"actorId": 101,
"actorName": "Sudeep",
"age": 45,
"industry": "Sandalwood",
"nationality": "Indian"
}
```
### Postman Screenshots
2. **Retrieve all actors**
- Method: GET
- URL: `http://localhost:8080/actors`
-
### Postman Screenshots
3. **Retrieve an actor by ID**
- Method: GET
- URL: `http://localhost:8080/actors/{id}`### Postman Screenshots
4. **Update an actor by ID**
- Method: PUT
- URL: `http://localhost:8080/actors/{id}`
- Body:
```json
{
"actorName": "Updated Name",
"age": 46,
"industry": "Updated Industry",
"nationality": "Updated Nationality"
}
```
### Postman Screenshots
5. **Delete an actor by ID**
- Method: DELETE
- URL: `http://localhost:8080/actors/{id}`
### Postman Screenshots
## Exception Handling
The application includes a robust exception handling mechanism to ensure that errors are properly managed and meaningful responses are returned to the client.### Key Components:
- **ActorNotFoundByIdException.java**: Custom exception thrown when an actor with the specified ID is not found in the database.
- **ActorNotFoundByNameException.java**: Custom exception thrown when an actor with the specified name is not found in the database.
- **ActorNotFoundByIndustryException.java**: Custom exception thrown when no actors are found in the specified industry within the database.
- **ActorNotFoundByAgeException.java**: Custom exception thrown when no actors matching the specified age criteria are found in the database.## Database
The application uses MySQL as the database to store actor information. Ensure that you have MySQL installed and configured before running the application.### MySQL Database Screenshots
## Conclusion
This project demonstrates a basic Spring Boot application with a layered architecture, including controllers, services, repositories, and entities. It provides a foundation for building more complex applications with Spring Boot.