From ecf2a329307e195df0d279c91b09432424600c21 Mon Sep 17 00:00:00 2001 From: Wonder Date: Tue, 7 Oct 2025 03:29:03 +0800 Subject: [PATCH] =?UTF-8?q?Update:=20T07/=E6=90=AD=E5=BB=BAapi-gateway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-gateway/pom.xml | 47 +++++++++++++++++++ .../apigateway/GatewayApplication.java | 13 +++++ api-gateway/src/main/resources/bootstrap.yml | 11 +++++ pom.xml | 3 +- service-producer/pom.xml | 5 ++ 5 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 api-gateway/pom.xml create mode 100644 api-gateway/src/main/java/cn/hezhaohui/apigateway/GatewayApplication.java create mode 100644 api-gateway/src/main/resources/bootstrap.yml diff --git a/api-gateway/pom.xml b/api-gateway/pom.xml new file mode 100644 index 0000000..a137e5f --- /dev/null +++ b/api-gateway/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + cn.hezhaohui + spring-cloud-template + 1.0-SNAPSHOT + + + api-gateway + + + 21 + 21 + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + + org.springframework.cloud + spring-cloud-starter-gateway + + + + org.springframework.cloud + spring-cloud-starter-bootstrap + + + + org.springframework.cloud + spring-cloud-starter-config + + + + \ No newline at end of file diff --git a/api-gateway/src/main/java/cn/hezhaohui/apigateway/GatewayApplication.java b/api-gateway/src/main/java/cn/hezhaohui/apigateway/GatewayApplication.java new file mode 100644 index 0000000..4c81612 --- /dev/null +++ b/api-gateway/src/main/java/cn/hezhaohui/apigateway/GatewayApplication.java @@ -0,0 +1,13 @@ +package cn.hezhaohui.apigateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class GatewayApplication { + public static void main(String[] args) { + SpringApplication.run(GatewayApplication.class, args); + } +} diff --git a/api-gateway/src/main/resources/bootstrap.yml b/api-gateway/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..2e9e19e --- /dev/null +++ b/api-gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,11 @@ +spring: + application: + name: api-gateway + cloud: + config: + uri: http://localhost:8888 + fail-fast: true +eureka: + client: + service-url: + defaultZone: http://localhost:8761/eureka/ \ No newline at end of file diff --git a/pom.xml b/pom.xml index 986fcc4..85acc9d 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ config-server service-producer service-consumer + api-gateway @@ -28,7 +29,7 @@ org.springframework.boot spring-boot-starter-parent - 3.2.2 + 3.3.13 pom import diff --git a/service-producer/pom.xml b/service-producer/pom.xml index 4ede68f..c4ed573 100644 --- a/service-producer/pom.xml +++ b/service-producer/pom.xml @@ -28,6 +28,11 @@ spring-cloud-netflix-eureka-client + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + org.springframework.cloud spring-cloud-starter-config