Spring Boot 2.1 缓存执行器不存在

Spring Boot 2.1 cache actuator not present

我已经根据版本 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 .

设置了一个简单的 spring 启动应用程序
@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");
    }
}

对于 pom.xml 我添加了缓存和执行器:

<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>

我也测试过

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

请注意,缓存执行器可用于 JMX,但在 Web 上。

原因是:

我遇到了类似的问题,结果发现执行器必须是spring-boot-autoconfigure-2.1.3.RELEASE.jar版本。

我之前的版本是 spring-boot-actuator-autoconfigure-2.0.2.RELEASE.jar。在此版本中,CachesEndpointAutoConfiguration 不存在。如果应用程序中存在 "cacheManager" bean,则此 class 负责创建 "cachesEndpoint" bean。

试用版本 2.1.3。