在主類添加@EnableCircuitBreaker或@SpringCloudApplication注解
我這邊的springboot是2.4,springcloud是2020.0.0-M5,應該是版本太高造成的
pom.xml里添加
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
或
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
或
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
會啟動報錯,如下:
java.lang.IllegalStateException: Annotation @EnableCircuitBreaker found,
but there are no implementations. Did you forget to include a starter?
解決方法:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
參考:
https://blog.csdn.net/qq_24585103/article/details/103126411