Q: How to initialize Spring application when Redis is not available? I need my Spring boot application to continue initializing whether the configured Redis server dependency is available or not.
On the other hand, this does not apply to the database, as I want to fail fast if DB is not available or has other initialization issues.
Simplest solution I found so far is the configuration option spring.datasource.continue-on-error=true, but this will also ignore database initialization errors, which is obviously not what I need.

A: If you are using JPA for DB mapping then it possible to do a lazy initialization of your Repository classes
@EnableJpaRepositories(bootstrapMode=BootstrapMode.LAZY)

In order to intialize Redis connection conditionally you can create a new class
@Configuration
@Profile("redisDB)
public class RedisDBConfiguration{
....
}


OR you can enable and disable Redis Repositories in properties based on different spring profiles
application.yml
spring:
  data:
    redis:
      repositories:
        enabled: false

