Java resilience4j springboot 2注释(@Retry,@CircuitBreaker)不工作
我正在开发一个springboot应用程序,希望添加resilience4j-重试机制。 我执行了以下步骤:Java resilience4j springboot 2注释(@Retry,@CircuitBreaker)不工作,java,circuit-breaker,resilience4j,resilience4j-retry,Java,Circuit Breaker,Resilience4j,Resilience4j Retry,我正在开发一个springboot应用程序,希望添加resilience4j-重试机制。 我执行了以下步骤: 在pom.xml中添加了执行器、aop和resilience4j依赖项 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </d
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot2</artifactId>
</dependency>
org.springframework.boot
弹簧靴起动器执行器
org.springframework.boot
弹簧启动机aop
io.github.resilience4j
弹性4J-spring-boot2
@GetMapping("/sample-api")
@Retry(name = "sample-api")
private String sampleApi() {
log.info("Sample Api call receieved");
ResponseEntity<String> forEntity = new RestTemplate().getForEntity("http://localhost:8080/some-dummy-url", String.class);
return forEntity.getBody();
}
@GetMapping(“/sample-api”)
@重试(name=“示例api”)
私有字符串sampleApi(){
log.info(“接收到样本Api调用”);
ResponseEntity forEntity=新建RestTemplate()。getForEntity(“http://localhost:8080/some-虚拟url”,String.class);
返回forEntity.getBody();
}
有人能帮忙吗?带注释的方法必须是公共的,而不是私有的。谢谢Robert。这起作用了。