Spring boot fails to start with Cache [product.result] specifies key/value types. Use getCache(String, Class, Class)

I need to cache the result for a few DB calls since it takes a very long time. I am trying to use EhCache. I am using Spring boot.

Below is my Repository class (which is in a separate module then my service class and RestController)

@Cacheable(value = "product.result", key="#term")
    public List<StoreProduct> getTopProductsForTerm(String term, int offset, int maxCount) {
        String query = GET_TOP_STORE_CATEGORY;
        Query nativeQuery = this.entityManager.createNativeQuery(query);
        nativeQuery.setParameter(1, maxCount);
        nativeQuery.setParameter(2, offset);
        nativeQuery.setParameter(3, term);
        return nativeQuery.getResultList();

Below is my ehcache.xml

    <!-- Persistent cache directory -->
    <persistence directory="spring-boot-ehcache/cache" />
    <!-- Default cache template -->
    <cache-template name="default">
            <ttl unit="seconds">604800</ttl>
            <offheap unit="MB">10</offheap>
            <disk persistent="true" unit="MB">20</disk>
    <cache alias="product.result" uses-template="default">

There was one answer on stackoverflow that suggest since we are using Spring, so we are no longer in control to define key type and value type. but when I remove these entry from ehcache.xml, I get another exception stating Keytype

Persisted key type 'java.lang.String' is not the same as the

If I define keytype only then it fails for value type with same exception If I specify both then it fails with exception

Cache [product.result] specifies key/value types. Use getCache(String, Class, Class)

I tried to use KeyGenerator as well but that also fails with same key-type mismatch. I followed this post https://dimitr.im/spring-boot-cache-ehcache to setup caching but it doesn't seems to work

I guess (and i am probably wrong) that there's cache manager specifically provided by Spring which is not activated

Below are dependencies that I used In module containing rest API (also tried defining in data module) org.springframework.boot spring-boot-starter-cache

In data module


Is there anything I am missing?