Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot 2.1 cache actuator not present

I have setup a simple spring boot application based on version 2.1 (https://github.com/dkellenb/spring-boot-2.1-cache-actuator-missing). I cannot find the reason why the cache actuator is not available at http://localhost:8080/actuator/caches .

@EnableCaching
@SpringBootApplication
@Controller
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
    @Cacheable(cacheNames = "helloWorld")
    @GetMapping
    public ResponseEntity<String> hello() {
        return ResponseEntity.ok("hello world");
    }
}

And for the pom.xml i have added cache and actuator:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-cache</artifactId>
</dependency>

Also i have tested with

endpoints.caches.enabled=true
management.endpoints.web.exposure.include=info,health,cache

Note that Cache Actuator is available with JMX, but on on web.

like image 768
D. Kellenberger Avatar asked Oct 21 '25 15:10

D. Kellenberger


2 Answers

The reason was:

  • cache is not exposed by default (see https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-endpoints-exposing-endpoints)
  • There was a typo for the exposure, it should be caches (plural)
like image 177
D. Kellenberger Avatar answered Oct 23 '25 03:10

D. Kellenberger


I had a similar problem and it turned out that the actuator must be be in the version spring-boot-autoconfigure-2.1.3.RELEASE.jar.

My previous version was spring-boot-actuator-autoconfigure-2.0.2.RELEASE.jar. In this version CachesEndpointAutoConfiguration not exist. This class is responsible for creating the "cachesEndpoint" bean if the "cacheManager" bean is present in the application.

Try the version 2.1.3.

like image 44
Mateusz Nowakowski Avatar answered Oct 23 '25 05:10

Mateusz Nowakowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!