Skip to content

@Cacheable not working on interface method in Spring Boot 1.4.2+ #8331

Closed
@ahmednasir91

Description

@ahmednasir91

We use Spring cache annotation

@Cacheable(cacheManager = "cacheManager", value = "cache-test", key = "'test-key2'")

This used to work well till Spring Boot 1.4.1 and the interface methods are annotated, since after upgrading to Spring Boot 1.4.3 & also tried the same on 1.4.4 the interface annotated methods have stopped working.

After digging deeper, we found it stops working with Spring Data JPA

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

If you exclude this repo, it starts working on interface methods.

This is the sample repo, to reproduce the issue https://github.com/ahmednasir91/spring-cache-test
The project has 3 branches

  • master SB v1.4.4 & Data JPA commented - Caching works on interface methods
  • cache-not-working SB 1.4.4, Data JPA enabled - Caching doesn't work for interface method
  • working-boot-1.4.1 SB 1.4.1 Data JPA enabled - Caching works on interface methods

Following are the APIs

These two have caching on interface
GET /test/hello2 
GET /test/hello

This one has on implementation
GET /test/hello-list

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions