Quick revision
The short answer
Start the application with --debug or debug=true to print the condition evaluation report, find RedisAutoConfiguration and read why it did or did not match; with Actuator, the conditions endpoint shows the same report at runtime. The usual causes are a missing starter or client library (spring-boot-starter-data-redis brings Spring Data Redis and Lettuce), our own bean making Boot's back off, or an injection point that asks for a RedisTemplate with generic types that Boot's RedisTemplate<Object, Object> does not match.
What to remember
In this answer, we used the condition evaluation report, from --debug or the Actuator conditions endpoint, to find out why RedisTemplate is missing. We read negative matches for RedisAutoConfiguration and its redisTemplate method and went through the common causes: a missing starter or client library, our own bean causing back-off, two connection factories, and an injection point whose generic types do not match Boot's RedisTemplate<Object, Object>.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Start the application with --debug or debug=true to print the condition evaluation report, find RedisAutoConfiguration and read why it did or did not match; with Actuator, the conditions endpoint shows the same report at runtime. The usual causes are a missing starter or client library (spring-boot-starter-data-redis brings Spring Data Redis and Lettuce), our own bean making Boot's back off, or an injection point that asks for a RedisTemplate with generic types that Boot's RedisTemplate<Object, Object> does not match.
Why this question is asked
A missing bean is one of the most common startup failures in Spring Boot, and RedisTemplate is a classic example because several different causes produce the same error. Guessing wastes time; Boot already keeps a precise record of every decision it made about auto-configuration. Interviewers ask this to see whether we reach for that record first. In this answer, we will recap where RedisTemplate comes from, print and read the condition report, use the Actuator endpoint, and go through the common causes with the evidence each one leaves.
1Where RedisTemplate Normally Comes From
RedisTemplate is Spring Data Redis's main helper class for talking to Redis. We do not usually create it ourselves. Boot's RedisAutoConfiguration creates two beans, a RedisTemplate<Object, Object> named redisTemplate and a StringRedisTemplate, both built on a RedisConnectionFactory that the same auto-configuration sets up with Lettuce, the default Redis client.
Each of those steps is guarded by conditions. The auto-configuration class needs RedisOperations, from Spring Data Redis, on the classpath. The redisTemplate bean is skipped if a bean named redisTemplate already exists, and it needs a single RedisConnectionFactory. So the question why is there no RedisTemplate becomes which of these conditions failed, and Boot can tell us.
- spring-boot-starter-data-redisbrings Spring Data Redis and Lettuce
- RedisAutoConfiguration
@ConditionalOnClass(RedisOperations) - RedisConnectionFactoryLettuce connection configuration
- redisTemplate bean
@ConditionalOnMissingBean(name = "redisTemplate"), single connection factory
4 layers, from the top down. Step through them one at a time.
2Printing the Condition Evaluation Report
Boot records the outcome of every condition it evaluated. Starting the application with --debug on the command line, or debug=true in application.properties, prints this record, the condition evaluation report, at startup. It has sections for positive matches, negative matches, exclusions and unconditional classes.
This example says the Spring Data Redis library is not on the classpath at all, so the whole auto-configuration was skipped. The --debug flag only turns on this report and debug logging for a few core loggers; it does not make the whole application log at DEBUG level. If the application fails to start, Boot prints a hint to rerun with debug enabled, and the report is printed even then.
3Using the Actuator Conditions Endpoint
For an application that is already running, we cannot restart it just to read the report. With Spring Boot Actuator, the conditions endpoint returns the same information as JSON, once it is exposed.
The endpoint exposes internal details, so it belongs behind authentication or only in non-production environments.
4Cause 1: Missing Starter or Client Library
The most common cause. Someone added only a Redis client such as Lettuce, or only a configuration property like spring.data.redis.host, assuming that is enough. The report shows RedisAutoConfiguration under negative matches with @ConditionalOnClass did not find required class RedisOperations. The fix is the starter, spring-boot-starter-data-redis, which brings both Spring Data Redis and Lettuce at versions that match the Boot release. A related variant is excluding Lettuce to use Jedis and forgetting to add Jedis, which leaves no connection factory.
5Cause 2: Our Own Bean Made Boot's Back Off
If RedisAutoConfiguration appears under positive matches but its redisTemplate method under negative matches, a condition on the bean failed. The usual reason is a bean of our own named redisTemplate, which makes Boot back off by name. That is fine if our bean is a RedisTemplate; it is a problem if, for example, a bean of a different type was given that name, or our bean is defined in a configuration class that is not loaded in this profile.
The report names the bean it found, so we can search for it. A second variant is two RedisConnectionFactory beans: the template requires a single candidate, so it is skipped with a message about the connection factory, and the fix is to mark one @Primary.
6Cause 3: The Bean Exists but the Generics Do Not Match
Sometimes the report shows redisTemplate under positive matches, yet startup still fails. Then the bean exists, and the problem is the injection point. Boot's bean is a RedisTemplate<Object, Object>. Spring matches generic types when injecting, so a field of type RedisTemplate<String, Order> does not match it.
- RedisAutoConfiguration in negative matches?check debug reportYesAdd the starter / clientNoLook at the bean method
- redisTemplate method in negative matches?YesFind the bean that made it back offNoBean exists
- Injection asks for specific generics?e.g.
RedisTemplate<String, Order>YesDefine a typed templateNoCheck qualifiers and profiles
3 steps in order. Play them, or step through them one at a time.
This is the cause people miss most, because the report looks healthy. The error message names the full generic type, which is the clue. Defining the typed template ourselves, with serializers chosen for our data, is the usual fix and often the better design anyway.
7Follow-up questions
Why is RedisTemplate<Object, Object> the default and not something more specific?
Boot cannot know our key and value types, so it provides the most general template with JDK serialization, plus a StringRedisTemplate for the common string case. For anything else, defining a template with explicit serializers, for example JSON, is expected.
Could the Redis auto-configuration be excluded?
Yes, through spring.autoconfigure.exclude or the exclude attribute of @SpringBootApplication, sometimes copied from another project. The report lists it under exclusions, so it is worth checking that section too.
What changed for Redis in Boot 4?
Boot 4 split auto-configuration into modules, so Redis support lives in its own module with a new package for RedisAutoConfiguration, and some property prefixes may differ. The diagnosis method is the same; check your version for exact names.
8Conclusion
In this answer, we used the condition evaluation report, from --debug or the Actuator conditions endpoint, to find out why RedisTemplate is missing. We read negative matches for RedisAutoConfiguration and its redisTemplate method and went through the common causes: a missing starter or client library, our own bean causing back-off, two connection factories, and an injection point whose generic types do not match Boot's RedisTemplate<Object, Object>.
Open with
I wouldn't guess; I'd ask Boot. Starting the application with --debug or debug=true prints the condition evaluation report, and with Actuator I can get the same thing from the conditions endpoint at runtime.
Then, if they want more
Then I look for RedisAutoConfiguration. If it's under negative matches with @ConditionalOnClass did not find RedisOperations, Spring Data Redis isn't on the classpath, usually because someone added only a client or only the host property, and the fix is spring-boot-starter-data-redis, which brings Spring Data Redis and Lettuce.
If the auto-configuration matched but its redisTemplate method didn't, the report says why: typically @ConditionalOnMissingBean found a bean named redisTemplate, so Boot backed off because of our own bean, or there are two connection factories and it needs a single candidate, so I mark one @Primary.
And if the report shows redisTemplate as created but startup still fails, I check the injection point. Boot's bean is a RedisTemplate of Object, Object, and Spring matches generics, so a field of RedisTemplate of String, Order finds no bean. I'd either inject StringRedisTemplate or the Object version, or define a typed template with proper serializers. I'd also check the exclusions section in case the auto-configuration was excluded.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Boot reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Your application starts but no RedisTemplate bean exists even though you think Redis is...": https://scrivio-interview-library.netlify.app/spring-boot/auto-configuration/4ad807bbae/