From 5c897c2f5b8dab723795a976399ff33f4e0bc6f7 Mon Sep 17 00:00:00 2001 From: GreyZeng <410486047@qq.com> Date: Tue, 22 Nov 2022 11:03:28 +0800 Subject: [PATCH] update --- .../src/main/resources/bootstrap.yml | 6 ++++-- .../user/controller/OrderController.java | 16 ---------------- .../user/controller/UserController2.java | 13 ------------- 3 files changed, 4 insertions(+), 31 deletions(-) delete mode 100644 skeleton-user-service/src/main/java/git/snippets/skeleton/user/controller/OrderController.java delete mode 100644 skeleton-user-service/src/main/java/git/snippets/skeleton/user/controller/UserController2.java diff --git a/skeleton-gateway/src/main/resources/bootstrap.yml b/skeleton-gateway/src/main/resources/bootstrap.yml index ee98bba..0854bfb 100644 --- a/skeleton-gateway/src/main/resources/bootstrap.yml +++ b/skeleton-gateway/src/main/resources/bootstrap.yml @@ -12,10 +12,12 @@ spring: cloud: gateway: routes: - - id: route_user_service + - id: sc-user-service uri: ${test.uri} # uri以lb://开头(lb代表从注册中心获取服务),后面接的就是你需要转发到的服务名称 predicates: - - Path=/user/** + - Path=/${spring.cloud.gateway.routes[0].id}/** + filters: + - StripPrefix=1 # 表示在转发时去掉 all test: uri: lb://sc-user-service diff --git a/skeleton-user-service/src/main/java/git/snippets/skeleton/user/controller/OrderController.java b/skeleton-user-service/src/main/java/git/snippets/skeleton/user/controller/OrderController.java deleted file mode 100644 index 1314761..0000000 --- a/skeleton-user-service/src/main/java/git/snippets/skeleton/user/controller/OrderController.java +++ /dev/null @@ -1,16 +0,0 @@ -package git.snippets.skeleton.user.controller; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Date; - -@RequestMapping("/order") -@RestController -public class OrderController { - - @RequestMapping("/info") - public String orderInfo() { - return "order info date : " + new Date(); - } -} \ No newline at end of file diff --git a/skeleton-user-service/src/main/java/git/snippets/skeleton/user/controller/UserController2.java b/skeleton-user-service/src/main/java/git/snippets/skeleton/user/controller/UserController2.java deleted file mode 100644 index 7e72ebe..0000000 --- a/skeleton-user-service/src/main/java/git/snippets/skeleton/user/controller/UserController2.java +++ /dev/null @@ -1,13 +0,0 @@ -package git.snippets.skeleton.user.controller; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RequestMapping("/user") -@RestController -public class UserController2 { - @RequestMapping("who") - public String who() { - return "lily"; - } -}