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.
- Java 23 or higher
- Maven 3.9.x or higher
- MySQL
- 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
- Create MySQL database
mysql -u root
CREATE DATABASE tododb;
- 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
- Build the project
mvn clean install
- Run the application
mvn spring-boot:run
The API will be available at http://localhost:8080
curl -X POST http://localhost:8080/api/todos \
-H "Content-Type: application/json" \
-d '{"title":"Learn Spring Boot","completed":false}'
curl http://localhost:8080/api/todos
curl http://localhost:8080/api/todos/1
curl -X PUT http://localhost:8080/api/todos/1 \
-H "Content-Type: application/json" \
-d '{"title":"Learn Spring Boot","completed":true}'
curl -X DELETE http://localhost:8080/api/todos/1
-
If MySQL connection fails:
- Verify MySQL is running:
brew services list
- Restart MySQL:
brew services restart mysql
- Verify MySQL is running:
-
If port 8080 is already in use:
- Change the port in
application.properties
:server.port=8081
- Change the port in
This project is licensed under the MIT License.