🔴 The Error You're Seeing

Confirm this matches your console output. If it does, you're in the right place.

ERROR LOG2026-02-20 11:30:45.001 ERROR 8842 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.IllegalStateException: No cache could be resolved for 'users' using name 'users'. Available caches are []] with root cause java.lang.IllegalStateException: No cache could be resolved for 'users' using name 'users'. Available caches are []

⚡ Quick Fix Works 80% of the time

Ensure @EnableCaching is present and a CacheManager bean is configured.

@EnableCaching @SpringBootApplication public class Application { ... }

🧠 Why this Happens

Tap to expand the deep technical explanation

You annotated a method with `@Cacheable("users")`, but Spring's caching engine could not find a cache named 'users'. This happens if you forgot to add `@EnableCaching`, didn't configure a `CacheManager` (like Caffeine or Redis), or forgot to explicitly create the cache name in the manager's configuration.

The HITEC City Parking Spot Analogy:

It's like a librarian asking to put a book in the 'Sci-Fi' section, but the library only has 'History' and 'Romance' shelves. The librarian throws an error because the specified shelf doesn't exist.

🔁 How to Reproduce Confirm this is your error

Add `@Cacheable("users")` to a service method. Do not add `@EnableCaching` to the main class. Run the app and call the method.

🛠️ Solutions (5 Ways to Fix)

Solution 1✓ Most common cause

Add @EnableCaching annotation

👉 Use this if you added caching annotations but forgot to turn on the engine.

This annotation activates Spring's caching infrastructure and looks for a CacheManager.

@EnableCaching @SpringBootApplication public class Application { ... }
Solution 2

Configure Caffeine cache names

👉 Use this when using in-memory Caffeine caching.

Explicitly define the caches available in your CacheManager configuration.

@Bean public CacheManager cacheManager() { CaffeineCacheManager cacheManager = new CaffeineCacheManager("users", "products"); return cacheManager; }
Solution 3

Configure Redis cache names

👉 Use this when using Redis as a distributed cache.

Define the cache configurations in a RedisCacheManager bean.

@Bean public CacheManager cacheManager(RedisConnectionFactory factory) { RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig(); return RedisCacheManager.builder(factory).cacheDefaults(config).build(); }
Solution 4

Fix typo in cache name

👉 Use this if the CacheManager exists but the error persists.

Ensure the string in `@Cacheable("users")` exactly matches the cache name configured in the CacheManager.

// Check for typos or case sensitivity issues @Cacheable("Users") // Bad if manager expects "users"
Solution 5

Exclude CacheAutoConfiguration

👉 Use this if you are not using caching but accidentally triggered it.

If you don't need caching, turn off the auto-configuration to prevent Spring from looking for a CacheManager.

@SpringBootApplication(exclude = {CacheAutoConfiguration.class}) public class Application { ... }

📋 Version Notes

Spring Boot 2.x

ConcurrentMapCacheManager is the default if no other manager is found.

Spring Boot 3.x

Stricter validation. Fails fast if `@Cacheable` is used without `@EnableCaching`.

🛡️ How to Prevent This Next Time

Always explicitly define your cache names in your CacheManager configuration rather than relying on auto-creation.