Set these environment variables before running your Spring Boot application:
# Redis Configuration
SPRING_REDIS_HOST=your-redis-host.cache.amazonaws.com
SPRING_REDIS_PORT=6379
SPRING_REDIS_PASSWORD=your-redis-password
SPRING_REDIS_SSL=true
# Database Configuration (if using cloud DB)
SPRING_DATASOURCE_URL=jdbc:postgresql://your-postgres-host:5432/your-database
DB_USER=your-db-username
DB_PASSWORD=your-db-password
# Encryption Key
ENCRYPTION_KEY=your-32-character-encryption-key-here# Redis Configuration
SPRING_REDIS_HOST=localhost
SPRING_REDIS_PORT=6379
SPRING_REDIS_PASSWORD=
SPRING_REDIS_SSL=false- Host:
your-cluster.cache.amazonaws.com - Port:
6379(or6380for SSL) - SSL:
true
- Host:
redis-12345.c1.us-east-1-1.ec2.cloud.redislabs.com - Port:
6379 - SSL:
true
- Host:
your-cache.redis.cache.windows.net - Port:
6380 - SSL:
true
$env:SPRING_REDIS_HOST="your-redis-host"
$env:SPRING_REDIS_PORT="6379"
$env:SPRING_REDIS_PASSWORD="your-password"
$env:SPRING_REDIS_SSL="true"set SPRING_REDIS_HOST=your-redis-host
set SPRING_REDIS_PORT=6379
set SPRING_REDIS_PASSWORD=your-password
set SPRING_REDIS_SSL=trueexport SPRING_REDIS_HOST=your-redis-host
export SPRING_REDIS_PORT=6379
export SPRING_REDIS_PASSWORD=your-password
export SPRING_REDIS_SSL=true- Set your environment variables
- Run the application:
mvn spring-boot:run - Check the console output for Redis connection status
- The
RedisConnectionTestwill show if the connection is successful
- Connection refused: Check if the Redis host and port are correct
- Authentication failed: Verify the password is correct
- SSL errors: Make sure SSL is enabled for cloud Redis services
- Timeout errors: Check if your firewall allows connections to the Redis port