diff --git a/cloud-demo/services/service-order/src/main/resources/application-dev.yaml b/cloud-demo/services/service-order/src/main/resources/application-dev.yaml deleted file mode 100644 index 8ba16c0..0000000 --- a/cloud-demo/services/service-order/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,3 +0,0 @@ -server: - port: 8000 - diff --git a/cloud-demo/services/service-order/src/main/resources/application-feign.yaml b/cloud-demo/services/service-order/src/main/resources/application-feign.yaml new file mode 100644 index 0000000..7d17590 --- /dev/null +++ b/cloud-demo/services/service-order/src/main/resources/application-feign.yaml @@ -0,0 +1,16 @@ +spring: + cloud: + openfeign: + client: + config: + # 对所有配置 + default: + logger-level: full + connect-timeout: 1000 + read-timeout: 1000 # 最多等待对方 5s + + # 对 service-product 单独设置 + service-product: + logger-level: full + connect-timeout: 3000 + read-timeout: 5000 # 最多等待对方 5s \ No newline at end of file diff --git a/cloud-demo/services/service-order/src/main/resources/application.yaml b/cloud-demo/services/service-order/src/main/resources/application.yaml index 4b9f087..cce3540 100644 --- a/cloud-demo/services/service-order/src/main/resources/application.yaml +++ b/cloud-demo/services/service-order/src/main/resources/application.yaml @@ -6,6 +6,8 @@ spring: name: service-order profiles: active: dev + include: + - feign cloud: nacos: server-addr: 192.168.95.135:8848 diff --git a/cloud-demo/services/service-product/src/main/java/cn/bunny/service/controller/ProductController.java b/cloud-demo/services/service-product/src/main/java/cn/bunny/service/controller/ProductController.java index 9e5e75a..e036da0 100644 --- a/cloud-demo/services/service-product/src/main/java/cn/bunny/service/controller/ProductController.java +++ b/cloud-demo/services/service-product/src/main/java/cn/bunny/service/controller/ProductController.java @@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.concurrent.TimeUnit; + @RestController @RequestMapping("/api/product") @RequiredArgsConstructor @@ -19,6 +21,11 @@ public class ProductController { @Operation(summary = "根据id查询商品") @GetMapping("{id}") public Product getProduct(@PathVariable("id") Long productId) { + try { + TimeUnit.SECONDS.sleep(6); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } return productService.getProductById(productId); } }