Skip to content

proSamik/Spring-Boot-Todo-List-API-with-Caching

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Todo List API with Caching

A REST API for managing todos with MySQL as primary database and H2 as a caching layer. The API supports CRUD operations with a two-layer caching system.

Getting Started

Prerequisites

  • Java 23 or higher
  • Maven 3.9.x or higher
  • MySQL

Installation & Setup

  1. Clone the repository
git clone https://github.com/proSamik/Spring-Boot-Todo-List-API-with-Caching.git
cd Spring-Boot-Todo-List-API-with-Caching
  1. Create MySQL database
mysql -u root
CREATE DATABASE tododb;
  1. Configure MySQL connection in src/main/resources/application.properties if needed
spring.datasource.username=root
spring.datasource.password=your_password  # Leave empty if no password
  1. Build the project
mvn clean install
  1. Run the application
mvn spring-boot:run

The API will be available at http://localhost:8080

Testing the API

Create a Todo

curl -X POST http://localhost:8080/api/todos \
-H "Content-Type: application/json" \
-d '{"title":"Learn Spring Boot","completed":false}'

Get all Todos

curl http://localhost:8080/api/todos

Get a specific Todo

curl http://localhost:8080/api/todos/1

Update a Todo

curl -X PUT http://localhost:8080/api/todos/1 \
-H "Content-Type: application/json" \
-d '{"title":"Learn Spring Boot","completed":true}'

Delete a Todo

curl -X DELETE http://localhost:8080/api/todos/1

Troubleshooting

  1. If MySQL connection fails:

    • Verify MySQL is running: brew services list
    • Restart MySQL: brew services restart mysql
  2. If port 8080 is already in use:

    • Change the port in application.properties:
      server.port=8081

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages