Forráskód Böngészése

0802 验证服务隔离

Qing 10 hónapja
szülő
commit
3142237cf9

+ 2 - 0
springcloud-demo/service-consumer-demo/src/main/resources/application.yml

@@ -49,6 +49,8 @@ feign:
   sentinel:
     enabled: true
 
+# 打印全日志补充的配置
+# 其中com.sf是自己项目的文件夹地址
 logging:
   level:
     com.sf: debug

+ 4 - 0
springcloud-demo/service-provider-demo/src/main/java/com/sf/controller/HelloController.java

@@ -1,20 +1,24 @@
 package com.sf.controller;
 
 import com.sf.dto.UserDto;
+import lombok.SneakyThrows;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Random;
+import java.util.concurrent.TimeUnit;
 
 @RestController
 public class HelloController {
 
     // http://localhost:8070/echo/helloProvider
+    @SneakyThrows
     @GetMapping("/echo/{string}")
     public String echo(@PathVariable("string") String string) {
         System.out.println("echo:" + string);
+        TimeUnit.SECONDS.sleep(1);
         return "echo:" + string;
     }