Bläddra i källkod

修改网关服务器,移出掉一代网关zuul,修改成二代网关spring cloud gateway.

yangzhijie 6 år sedan
förälder
incheckning
b6ee55a903
3 ändrade filer med 49 tillägg och 56 borttagningar
  1. 1 1
      pom.xml
  2. 0 2
      src/main/java/com/leanwo/gateway/GatewayApp.java
  3. 48 53
      src/main/resources/Application.yml

+ 1 - 1
pom.xml

@@ -44,7 +44,7 @@
 
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
+			<artifactId>spring-cloud-starter-gateway</artifactId>
 		</dependency>
 
 		<dependency>

+ 0 - 2
src/main/java/com/leanwo/gateway/GatewayApp.java

@@ -5,14 +5,12 @@ import org.slf4j.LoggerFactory;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
 
 import com.leanwo.gateway.util.ProgramStopUtil;
 
 
 @SpringBootApplication
 @EnableDiscoveryClient//开启Eureka的客户端发现
-@EnableZuulProxy// 开启Zuul的网关功能
 public class GatewayApp {
 	
 	private static Logger logger = LoggerFactory.getLogger(GatewayApp.class);

+ 48 - 53
src/main/resources/Application.yml

@@ -18,7 +18,54 @@ spring:
       maxFileSize: 100MB
       # 总文件大小
       maxRequestSize: 200MB
-
+  cloud:
+    gateway:
+      discovery:
+        locator:
+          enabled: true
+      routes:
+        - id: application_server
+          uri: lb://prodog-server
+          predicates:
+            - Path=/api/**
+        - id: dingtalk_server
+          uri: lb://dingtalk-server
+          predicates:
+            - Path=/dingTalkApi/**
+          filters:
+            - StripPrefix=1
+        # 正式的环境去掉该配置
+        - id: pc_client
+          uri: http://127.0.0.1:8081
+          predicates:
+            - Path=/pcapp/**
+        # 正式的环境去掉该配置
+        - id: pc_client_static
+          uri: http://127.0.0.1:8081
+          predicates:
+            - Path=/static/**
+        # 正式的环境去掉该配置
+        - id: wms_client_static
+          uri: http://127.0.0.1:8083
+          predicates:
+            - Path=/static-wms-app/**
+        # 正式的环境去掉该配置
+        - id: wms_client
+          uri: http://127.0.0.1:8083
+          predicates:
+            - Path=/wmsapp/**
+        # 正式的环境去掉该配置
+        - id: eam_client
+          uri: http://127.0.0.1:8082
+          predicates:
+            - Path=/eamapp/**
+        # 文件服务器
+        - id: file_server
+          uri: lb://file-server
+          predicates:
+            - Path=/**
+          
+          
 #Eureka Server服务器地址.
 eureka:
   instance:
@@ -33,58 +80,6 @@ eureka:
     serviceUrl:
       defaultZone: http://localhost:88/eureka/
 
-zuul:
-  #  隐藏所有微服务名称(即使用微服务名称无法访问到服务)
-  ignored-services: "*"
-  #添加主机头
-  addHostHeader: true
-  #是否默认支持重试
-  retryable: true
-  #路由前缀,想要访问项目之前要加上此路径
-  prefix: /
-  routes:
-    applicationserver:
-      path: /api/**
-      serviceId: prodog-server
-      # 去除路由前缀,默认为true,改为false即使user-serivce这条路由的/api路径不做去除
-      strip-prefix: false
-    dingtalkserver:
-      path: /dingTalkApi/**
-      serviceId: dingtalk-server
-      strip-prefix: true
-    # 正式的环境去掉该配置
-    wmsclient:
-      path: /wmsapp/**
-      url: http://127.0.0.1:8083
-      strip-prefix: false
-    # 正式的环境去掉该配置
-    wmsclient-static:
-      path: /static-wms-app/**
-      url: http://127.0.0.1:8083
-      strip-prefix: false
-    # 正式的环境去掉该配置
-    pcclient:
-      path: /pcapp/**
-      url: http://127.0.0.1:8081
-      strip-prefix: false
-    # 正式的环境去掉该配置
-    pcclient-static:
-      path: /static/**
-      url: http://127.0.0.1:8081
-      strip-prefix: false
-    # 正式的环境去掉该配置
-    eamclient:
-      path: /eamapp/**
-      url: http://127.0.0.1:8082
-      strip-prefix: false
-      
-    #stwc服务器跳转
-    stwcserver:
-      path: /StwcApp/**
-      url: forward:http://stwc.leanwo.com/StwcApp/
-    fileserver:
-      path: /**
-      serviceId: file-server
     
       
 ribbon: