From 312073ed9f8e2659954485544f841f505799053a Mon Sep 17 00:00:00 2001
From: zhangmeng <1334717033@qq.com>
Date: Sat, 30 Oct 2021 18:08:08 +0800
Subject: [PATCH] first
---
mystyle-cloud-file/pom.xml | 45 +++++++++++++++
.../com/zhangmeng/file/FileApplication.java | 16 ++++++
.../file/controller/FileController.java | 20 +++++++
.../file/feign/UserFeignService.java | 14 +++++
.../src/main/resources/application.yml | 19 +++++++
mystyle-cloud-gateway/pom.xml | 57 +++++++++++++++++++
.../zhangmeng/gateway/GateWayApplication.java | 14 +++++
.../src/main/resources/application.yml | 40 +++++++++++++
mystyle-cloud-user/pom.xml | 43 ++++++++++++++
.../com/zhangmeng/user/UserApplication.java | 19 +++++++
.../user/controller/UserController.java | 21 +++++++
.../src/main/resources/application.yml | 26 +++++++++
pom.xml | 52 +++++++++++++++++
13 files changed, 386 insertions(+)
create mode 100644 mystyle-cloud-file/pom.xml
create mode 100644 mystyle-cloud-file/src/main/java/com/zhangmeng/file/FileApplication.java
create mode 100644 mystyle-cloud-file/src/main/java/com/zhangmeng/file/controller/FileController.java
create mode 100644 mystyle-cloud-file/src/main/java/com/zhangmeng/file/feign/UserFeignService.java
create mode 100644 mystyle-cloud-file/src/main/resources/application.yml
create mode 100644 mystyle-cloud-gateway/pom.xml
create mode 100644 mystyle-cloud-gateway/src/main/java/com/zhangmeng/gateway/GateWayApplication.java
create mode 100644 mystyle-cloud-gateway/src/main/resources/application.yml
create mode 100644 mystyle-cloud-user/pom.xml
create mode 100644 mystyle-cloud-user/src/main/java/com/zhangmeng/user/UserApplication.java
create mode 100644 mystyle-cloud-user/src/main/java/com/zhangmeng/user/controller/UserController.java
create mode 100644 mystyle-cloud-user/src/main/resources/application.yml
create mode 100644 pom.xml
diff --git a/mystyle-cloud-file/pom.xml b/mystyle-cloud-file/pom.xml
new file mode 100644
index 0000000..b52a4ee
--- /dev/null
+++ b/mystyle-cloud-file/pom.xml
@@ -0,0 +1,45 @@
+
+
+
+ mystyle-cloud-parent
+ com.zhangmeng
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ mystyle-cloud-file
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-sleuth
+
+
+
+ org.springframework.cloud
+ spring-cloud-sleuth-zipkin
+
+
+
\ No newline at end of file
diff --git a/mystyle-cloud-file/src/main/java/com/zhangmeng/file/FileApplication.java b/mystyle-cloud-file/src/main/java/com/zhangmeng/file/FileApplication.java
new file mode 100644
index 0000000..2234029
--- /dev/null
+++ b/mystyle-cloud-file/src/main/java/com/zhangmeng/file/FileApplication.java
@@ -0,0 +1,16 @@
+package com.zhangmeng.file;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients
+public class FileApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(FileApplication.class,args);
+ }
+}
diff --git a/mystyle-cloud-file/src/main/java/com/zhangmeng/file/controller/FileController.java b/mystyle-cloud-file/src/main/java/com/zhangmeng/file/controller/FileController.java
new file mode 100644
index 0000000..11955cd
--- /dev/null
+++ b/mystyle-cloud-file/src/main/java/com/zhangmeng/file/controller/FileController.java
@@ -0,0 +1,20 @@
+package com.zhangmeng.file.controller;
+
+import com.zhangmeng.file.feign.UserFeignService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/file")
+public class FileController {
+
+ @Autowired
+ private UserFeignService userFeignService;
+
+ @GetMapping("/name")
+ public String file_name(String name){
+ return this.userFeignService.hi(name);
+ }
+}
diff --git a/mystyle-cloud-file/src/main/java/com/zhangmeng/file/feign/UserFeignService.java b/mystyle-cloud-file/src/main/java/com/zhangmeng/file/feign/UserFeignService.java
new file mode 100644
index 0000000..d4a96d2
--- /dev/null
+++ b/mystyle-cloud-file/src/main/java/com/zhangmeng/file/feign/UserFeignService.java
@@ -0,0 +1,14 @@
+package com.zhangmeng.file.feign;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@FeignClient(value = "mystyle-cloud-user")
+@RequestMapping("/user")
+public interface UserFeignService {
+
+ @GetMapping("/username")
+ public String hi(@RequestParam(value = "name", defaultValue = "forezp",required = false) String name);
+}
diff --git a/mystyle-cloud-file/src/main/resources/application.yml b/mystyle-cloud-file/src/main/resources/application.yml
new file mode 100644
index 0000000..1abad38
--- /dev/null
+++ b/mystyle-cloud-file/src/main/resources/application.yml
@@ -0,0 +1,19 @@
+server:
+ port: 8763
+
+spring:
+ application:
+ name: mystyle-cloud-file
+ zipkin:
+ sender:
+ type: web
+ base-url: http://localhost:9411/
+ service:
+ name: mystyle-cloud-file
+ sleuth:
+ sampler:
+ probability: 1
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
\ No newline at end of file
diff --git a/mystyle-cloud-gateway/pom.xml b/mystyle-cloud-gateway/pom.xml
new file mode 100644
index 0000000..467caba
--- /dev/null
+++ b/mystyle-cloud-gateway/pom.xml
@@ -0,0 +1,57 @@
+
+
+
+ mystyle-cloud-parent
+ com.zhangmeng
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ mystyle-cloud-gateway
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ org.springframework.cloud
+ spring-cloud-starter-gateway
+
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-sentinel-gateway
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-sleuth
+
+
+
+ org.springframework.cloud
+ spring-cloud-sleuth-zipkin
+
+
+
+
+
\ No newline at end of file
diff --git a/mystyle-cloud-gateway/src/main/java/com/zhangmeng/gateway/GateWayApplication.java b/mystyle-cloud-gateway/src/main/java/com/zhangmeng/gateway/GateWayApplication.java
new file mode 100644
index 0000000..a667c48
--- /dev/null
+++ b/mystyle-cloud-gateway/src/main/java/com/zhangmeng/gateway/GateWayApplication.java
@@ -0,0 +1,14 @@
+package com.zhangmeng.gateway;
+
+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/mystyle-cloud-gateway/src/main/resources/application.yml b/mystyle-cloud-gateway/src/main/resources/application.yml
new file mode 100644
index 0000000..9fa2aec
--- /dev/null
+++ b/mystyle-cloud-gateway/src/main/resources/application.yml
@@ -0,0 +1,40 @@
+server:
+ port: 5000
+spring:
+ application:
+ name: mystyle-cloud-gateway
+ zipkin:
+ sender:
+ type: web
+ base-url: http://localhost:9411/
+ service:
+ name: mystyle-cloud-gateway
+ sleuth:
+ sampler:
+ probability: 1
+ cloud:
+ sentinel:
+ transport:
+ port: 15000
+ dashboard: localhost:8748
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
+ gateway:
+ discovery:
+ locator:
+ enabled: false
+ lowerCaseServiceId: true
+ routes:
+ - id: mystyle-cloud-file
+ uri: lb://mystyle-cloud-file
+ predicates:
+ - Path=/mystyle-file/**
+ filters:
+ - StripPrefix=1
+ - id: mystyle-cloud-user
+ uri: lb://mystyle-cloud-user
+ predicates:
+ - Path=/mystyle-user/**
+ filters:
+ - StripPrefix=1
\ No newline at end of file
diff --git a/mystyle-cloud-user/pom.xml b/mystyle-cloud-user/pom.xml
new file mode 100644
index 0000000..fd62cc6
--- /dev/null
+++ b/mystyle-cloud-user/pom.xml
@@ -0,0 +1,43 @@
+
+
+
+ mystyle-cloud-parent
+ com.zhangmeng
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ mystyle-cloud-user
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-sleuth
+
+
+
+ org.springframework.cloud
+ spring-cloud-sleuth-zipkin
+
+
+
+
\ No newline at end of file
diff --git a/mystyle-cloud-user/src/main/java/com/zhangmeng/user/UserApplication.java b/mystyle-cloud-user/src/main/java/com/zhangmeng/user/UserApplication.java
new file mode 100644
index 0000000..ae1faa0
--- /dev/null
+++ b/mystyle-cloud-user/src/main/java/com/zhangmeng/user/UserApplication.java
@@ -0,0 +1,19 @@
+package com.zhangmeng.user;
+
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+
+/**
+ * @author zhangmeng
+ * @date 2021年10月30日14:55:11
+ * @version 1.0
+ */
+@SpringBootApplication
+@EnableDiscoveryClient
+public class UserApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(UserApplication.class,args);
+ }
+}
diff --git a/mystyle-cloud-user/src/main/java/com/zhangmeng/user/controller/UserController.java b/mystyle-cloud-user/src/main/java/com/zhangmeng/user/controller/UserController.java
new file mode 100644
index 0000000..53d46b6
--- /dev/null
+++ b/mystyle-cloud-user/src/main/java/com/zhangmeng/user/controller/UserController.java
@@ -0,0 +1,21 @@
+package com.zhangmeng.user.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.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/user")
+public class UserController {
+
+ @Value("${server.port}")
+ String port;
+
+ @GetMapping("/username")
+ public String hi(@RequestParam(value = "name", defaultValue = "forezp",required = false) String name) {
+ return "hello " + name + ", i'm provider ,my port:" + port;
+
+ }
+}
diff --git a/mystyle-cloud-user/src/main/resources/application.yml b/mystyle-cloud-user/src/main/resources/application.yml
new file mode 100644
index 0000000..308b089
--- /dev/null
+++ b/mystyle-cloud-user/src/main/resources/application.yml
@@ -0,0 +1,26 @@
+server:
+ port: 8762
+spring:
+ application:
+ name: mystyle-cloud-user
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
+ sentinel:
+ transport:
+ port: 18763
+ dashboard: localhost:8748
+ zipkin:
+ sender:
+ type: web
+ base-url: http://localhost:9411/
+ service:
+ name: mystyle-cloud-user
+ sleuth:
+ sampler:
+ probability: 1
+
+feign:
+ sentinel:
+ enabled: true
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..70c8463
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,52 @@
+
+
+ 4.0.0
+
+ com.zhangmeng
+ mystyle-cloud-parent
+ pom
+ 1.0-SNAPSHOT
+
+ mystyle-cloud-user
+ mystyle-cloud-file
+ mystyle-cloud-gateway
+
+
+
+ 1.8
+ 2.4.4
+ 2020.0.2
+ 2020.0.RC1
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot.version}
+ pom
+ import
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ ${spring-cloud-alibaba.version}
+ pom
+ import
+
+
+
+
\ No newline at end of file