From f4c6b381752ae61003982f7205df72d1cf73badb Mon Sep 17 00:00:00 2001 From: Bunny <1319900154@qq.com> Date: Mon, 10 Feb 2025 18:23:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(gateway):=20=E5=BC=95=E5=85=A5=E7=BD=91?= =?UTF-8?q?=E7=AE=A1=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gateway/pom.xml | 34 +++++++++++++++++++ .../java/cn/bunny/GatewayMainApplication.java | 13 +++++++ .../src/main/resources/application-route.yml | 12 +++++++ gateway/src/main/resources/application.yml | 12 +++++++ pom.xml | 10 ++++++ 5 files changed, 81 insertions(+) create mode 100644 gateway/pom.xml create mode 100644 gateway/src/main/java/cn/bunny/GatewayMainApplication.java create mode 100644 gateway/src/main/resources/application-route.yml create mode 100644 gateway/src/main/resources/application.yml diff --git a/gateway/pom.xml b/gateway/pom.xml new file mode 100644 index 0000000..946f76a --- /dev/null +++ b/gateway/pom.xml @@ -0,0 +1,34 @@ + + 4.0.0 + + cn.bunny + cloud1 + 0.0.1-SNAPSHOT + + + gateway + jar + + gateway + https://maven.apache.org + + + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-gateway + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + diff --git a/gateway/src/main/java/cn/bunny/GatewayMainApplication.java b/gateway/src/main/java/cn/bunny/GatewayMainApplication.java new file mode 100644 index 0000000..917fb0c --- /dev/null +++ b/gateway/src/main/java/cn/bunny/GatewayMainApplication.java @@ -0,0 +1,13 @@ +package cn.bunny; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@EnableDiscoveryClient +@SpringBootApplication +public class GatewayMainApplication { + public static void main(String[] args) { + SpringApplication.run(GatewayMainApplication.class, args); + } +} diff --git a/gateway/src/main/resources/application-route.yml b/gateway/src/main/resources/application-route.yml new file mode 100644 index 0000000..f6de2c9 --- /dev/null +++ b/gateway/src/main/resources/application-route.yml @@ -0,0 +1,12 @@ +spring: + cloud: + gateway: + routes: + - id: service-cloud1 + uri: lb://service-cloud1 + predicates: + - Path=/api/** + - id: service-cloud2 + uri: lb://service-cloud2 + predicates: + - Path=/api/** diff --git a/gateway/src/main/resources/application.yml b/gateway/src/main/resources/application.yml new file mode 100644 index 0000000..b522053 --- /dev/null +++ b/gateway/src/main/resources/application.yml @@ -0,0 +1,12 @@ +server: + port: 8800 +spring: + application: + name: service-gateway + profiles: + include: + - route + cloud: + nacos: + server-addr: 192.168.3.132 + diff --git a/pom.xml b/pom.xml index 2938d55..c1fb146 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,7 @@ service common dao + gateway @@ -64,4 +65,13 @@ + + + + + org.springframework.boot + spring-boot-maven-plugin + + +