This is a RESTful API for an inventory management system, developed as part of a personal Java challenge. It provides a set of endpoints for performing standard CRUD operations on inventory items.
- Create new items in the inventory.
- Read all items or a single item by its ID.
- Update an existing item's details.
- Delete an item from the inventory.
- Spring Boot: The core framework for building the backend.
- Spring Data JPA: For handling data persistence to a MySQL database.
- Lombok: To reduce boilerplate code in model classes.
- MySQL: The relational database used for data storage.
- Logback: For robust and configurable application logging.
First, you need to configure your database connection in the src/main/resources/application.properties
file.
# Database Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/inventory_db?createDatabaseIfNotExist=true
spring.datasource.username=your_username
spring.datasource.password=your_password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# JPA Configuration
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
# Server port
server.port=8080
# log pattern configuration
logging.pattern.console= [%thread] %-5level: %logger - %msg%n
# log level configuration
logging.level.root=INFO
Make sure to replace your_username
and your_password
with your actual MySQL credentials.
Once the database is configured, you can run the application directly from your IDE by executing the EmployeeApplication.java
main class.
Alternatively, you can build and run the application using Maven. Navigate to the project directory and execute the following commands:
mvn spring-boot:run
This will start the application on http://localhost:8080/inventory-app
.
The following endpoints are available for managing inventory items:
-
GET
/inventory-app/items
: Get a list of all items. -
POST
/inventory-app/items
: Add a new item. -
GET
/inventory-app/items/{id}
: Get a specific item by its ID. -
PUT
/inventory-app/items/{id}
: Update an existing item by its ID. -
DELETE
/inventory-app/items/{id}
: Delete an item by its ID.