From 371e825200e599d99fda2453b4fc2fdfcb13bca0 Mon Sep 17 00:00:00 2001 From: Wonder Date: Mon, 6 Oct 2025 19:20:04 +0800 Subject: [PATCH] =?UTF-8?q?Update:=20T04/=E6=90=AD=E5=BB=BAservice-produce?= =?UTF-8?q?r=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 2 +- pom.xml | 1 + service-producer/pom.xml | 42 +++++++++++++++++++ .../ServiceProducerApplication.java | 12 ++++++ .../controller/HealthController.java | 19 +++++++++ .../src/main/resources/bootstrap.yml | 11 +++++ 6 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 service-producer/pom.xml create mode 100644 service-producer/src/main/java/cn/hezhaohui/serviceproducer/ServiceProducerApplication.java create mode 100644 service-producer/src/main/java/cn/hezhaohui/serviceproducer/controller/HealthController.java create mode 100644 service-producer/src/main/resources/bootstrap.yml diff --git a/config-server/src/main/resources/application.yml b/config-server/src/main/resources/application.yml index 9e34d24..7905d49 100644 --- a/config-server/src/main/resources/application.yml +++ b/config-server/src/main/resources/application.yml @@ -7,7 +7,7 @@ spring: config: server: git: - uri: xxxxx + uri: http://47.121.181.112:3000/wonder/spring-cloud-config search-paths: config-files eureka: diff --git a/pom.xml b/pom.xml index 30f52f7..769ea9d 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ eureka-server config-server + service-producer diff --git a/service-producer/pom.xml b/service-producer/pom.xml new file mode 100644 index 0000000..4ede68f --- /dev/null +++ b/service-producer/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + + cn.hezhaohui + spring-cloud-template + 1.0-SNAPSHOT + + + service-producer + + + 21 + 21 + UTF-8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.cloud + spring-cloud-netflix-eureka-client + + + + org.springframework.cloud + spring-cloud-starter-config + + + + org.springframework.cloud + spring-cloud-starter-bootstrap + + + + \ No newline at end of file diff --git a/service-producer/src/main/java/cn/hezhaohui/serviceproducer/ServiceProducerApplication.java b/service-producer/src/main/java/cn/hezhaohui/serviceproducer/ServiceProducerApplication.java new file mode 100644 index 0000000..1825219 --- /dev/null +++ b/service-producer/src/main/java/cn/hezhaohui/serviceproducer/ServiceProducerApplication.java @@ -0,0 +1,12 @@ +package cn.hezhaohui.serviceproducer; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication + +public class ServiceProducerApplication { + public static void main(String[] args) { + SpringApplication.run(ServiceProducerApplication.class, args); + } +} diff --git a/service-producer/src/main/java/cn/hezhaohui/serviceproducer/controller/HealthController.java b/service-producer/src/main/java/cn/hezhaohui/serviceproducer/controller/HealthController.java new file mode 100644 index 0000000..e98ce7b --- /dev/null +++ b/service-producer/src/main/java/cn/hezhaohui/serviceproducer/controller/HealthController.java @@ -0,0 +1,19 @@ +package cn.hezhaohui.serviceproducer.controller; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api") +public class HealthController { + + @Value("${test.message}") + private String testMessage; + + @GetMapping("/health") + public String health() { + return "Wow, nice to meet you!" + "\n" + testMessage; + } +} diff --git a/service-producer/src/main/resources/bootstrap.yml b/service-producer/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..e23cfc0 --- /dev/null +++ b/service-producer/src/main/resources/bootstrap.yml @@ -0,0 +1,11 @@ +spring: + application: + name: service-producer + cloud: + config: + uri: http://localhost:8888 + fail-fast: true +eureka: + client: + service-url: + defaultZone: http://localhost:8761/eureka \ No newline at end of file