Skip to content

redis-developer/redis-starter-java

Repository files navigation

This is a Redis starter template for Java and Spring Boot 4.

Requirements

  • Java 17+
  • Docker

The project uses the included Maven wrapper, so a separate Maven install is optional.

Environment

Copy the sample environment file:

cp .env.example .env

Supported variables:

  • REDIS_URL
  • PORT
  • LOG_LEVEL
  • LOG_STREAM_KEY
  • NODE_ENV

.env is optional at runtime. Spring will use real environment variables and command-line properties first, then fall back to .env values when present.

.env.docker contains compose-safe defaults for the bundled Redis service.

Run with Docker

docker compose up -d

This starts Redis 8 and the API server. The app is available at http://localhost:8080 unless PORT is overridden. Redis stays on the internal compose network by default, so it does not claim host port 6379.

Run locally

Point REDIS_URL at Redis Stack / Redis Cloud, then start the app with:

./mvnw spring-boot:run

API

  • GET /api/todos lists all todos
  • GET /api/todos/search?name=<name>&status=<status> searches by name and/or status
  • GET /api/todos/{id} fetches a single todo
  • POST /api/todos creates a todo from { "name": "Sample todo" }
  • PATCH /api/todos/{id} updates status from { "status": "todo|in progress|complete" }
  • DELETE /api/todos/{id} deletes a todo

Notes:

  • GET /api/todos/search is the primary search route.
  • Trailing-slash route aliases are still accepted for compatibility.
  • Error responses use { "status": <int>, "message": <string> }.
  • Todo timestamps are returned as createdDate and updatedDate.

Tests

Run the full test suite with:

./mvnw test

Tests use Testcontainers and start Redis automatically. You do not need a pre-running Redis server or a local .env file.

Redis Cloud

If you do not already have a database, start here:

Use the endpoint, username, and password from Redis Cloud to build a connection string such as:

REDIS_URL="redis://default:<password>@redis-#####.c###.us-west-2-#.ec2.redns.redis-cloud.com:#####"

Learn More

Releases

No releases published

Packages

 
 
 

Contributors