diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/README-zh.md b/spring-cloud-tencent-examples/polaris-quickstart-example/README-zh.md
index c09e8392..25480266 100644
--- a/spring-cloud-tencent-examples/polaris-quickstart-example/README-zh.md
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/README-zh.md
@@ -8,7 +8,7 @@
### 修改配置
-修改bootstrap.yml,修改后配置如下所示。其中,${ip}和${port}为Polaris后端服务的IP地址与端口号。
+在 polaris-quickstart-example/quickstart-provider 以及 polaris-quickstart-example/quickstart-consumer 两个项目中,修改bootstrap.yml,修改后配置如下所示。其中,${ip}和${port}为Polaris后端服务的IP地址与端口号。
```yaml
spring:
@@ -21,15 +21,15 @@ spring:
### 启动样例
-#### 启动应用
+#### 启动Provider
- IDEA启动
-找到 polaris-quickstart-example 项目的主类 EchoServiceApplication,执行 main 方法启动样例。
+ 找到 polaris-quickstart-example/quickstart-provider 项目的主类 EchoServerApplication,执行 main 方法启动样例。
- Maven打包启动
-在```spring-cloud-tencent-examples/polaris-quickstart-example```下执行
+在```polaris-quickstart-example/quickstart-provider```下执行
```sh
mvn clean package
@@ -41,14 +41,42 @@ mvn clean package
java -jar ${app.jar}
```
-启动应用,其中${app.jar}替换为对应的jar包名。
+启动应用,其中`${app.jar}`替换为对应的jar包名。
+
+#### 启动Consumer
+
+- IDEA启动
+
+ 找到 polaris-quickstart-example/quickstart-consumer 项目的主类 EchoClientApplication,执行 main 方法启动样例。
+
+- Maven打包启动
+
+在```polaris-quickstart-example/quickstart-consumer```下执行
+
+```sh
+mvn clean package
+```
+
+然后找到生成的jar包,运行
+
+```
+java -jar ${app.jar}
+```
+
+启动应用,其中`${app.jar}`替换为对应的jar包名。
### 验证
#### HTTP调用
+Consumer 和 Provider 启动端口都是随机生成的,因此需要记录Consumer启动时候的端口:
+```
+11:26:53 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 58838 (http) with context path ''
+```
+执行http调用,其中`${app.port}`替换为启动的端口。
```shell
-curl -L -X GET 'http://localhost:47080/quickstart/feign?msg=hello_world''
+curl -L -X GET 'http://localhost:${app.port}/echo?value=hello_world''
```
-预期返回值:hello_world
\ No newline at end of file
+预期返回值:`echo: hello_world`
+
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/pom.xml b/spring-cloud-tencent-examples/polaris-quickstart-example/pom.xml
index d2ddebca..92a83dff 100644
--- a/spring-cloud-tencent-examples/polaris-quickstart-example/pom.xml
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/pom.xml
@@ -11,19 +11,12 @@
4.0.0
polaris-quickstart-example
+ Spring Cloud Tencent Polaris QuickStart Example
+
+ pom
+
+ quickstart-provider
+ quickstart-consumer
+
-
-
- spring-cloud-starter-tencent-polaris-discovery
- com.tencent.cloud
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.cloud
- spring-cloud-starter-openfeign
-
-
\ No newline at end of file
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/pom.xml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/pom.xml
new file mode 100644
index 00000000..51ee5d94
--- /dev/null
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/pom.xml
@@ -0,0 +1,38 @@
+
+
+
+ polaris-quickstart-example
+ com.tencent.cloud
+ ${revision}
+ ../pom.xml
+
+ 4.0.0
+
+ quickstart-consumer
+
+
+
+ spring-cloud-starter-tencent-polaris-discovery
+ com.tencent.cloud
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
\ No newline at end of file
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/src/main/java/com/tencent/cloud/polaris/quickstart/example/EchoServiceApplication.java b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientApplication.java
similarity index 85%
rename from spring-cloud-tencent-examples/polaris-quickstart-example/src/main/java/com/tencent/cloud/polaris/quickstart/example/EchoServiceApplication.java
rename to spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientApplication.java
index e0990673..9819c5ea 100644
--- a/spring-cloud-tencent-examples/polaris-quickstart-example/src/main/java/com/tencent/cloud/polaris/quickstart/example/EchoServiceApplication.java
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientApplication.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.polaris.quickstart.example;
+package com.tencent.cloud.polaris.quickstart.consumer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -25,9 +25,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
-public class EchoServiceApplication {
+public class EchoClientApplication {
public static void main(String[] args) {
- SpringApplication.run(EchoServiceApplication.class, args);
+ SpringApplication.run(EchoClientApplication.class, args);
}
}
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/src/main/java/com/tencent/cloud/polaris/quickstart/example/EchoController.java b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientController.java
similarity index 73%
rename from spring-cloud-tencent-examples/polaris-quickstart-example/src/main/java/com/tencent/cloud/polaris/quickstart/example/EchoController.java
rename to spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientController.java
index 643bfe89..e8f75cef 100644
--- a/spring-cloud-tencent-examples/polaris-quickstart-example/src/main/java/com/tencent/cloud/polaris/quickstart/example/EchoController.java
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientController.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.polaris.quickstart.example;
+package com.tencent.cloud.polaris.quickstart.consumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -24,22 +24,16 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
-@RequestMapping("/quickstart")
-public class EchoController {
+@RequestMapping("/")
+public class EchoClientController {
+
@Autowired
- private EchoService echoService;
+ private EchoServer echoServer;
@GetMapping("/echo")
- public String echo(@RequestParam String msg) {
- return "echo: " + msg;
- }
-
- @GetMapping("/feign")
- public String feign(@RequestParam String msg) {
- return echoService.echo(msg);
+ public String echo(@RequestParam String value) {
+ return echoServer.echo(value);
}
}
-
-
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/src/main/java/com/tencent/cloud/polaris/quickstart/example/EchoService.java b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoServer.java
similarity index 82%
rename from spring-cloud-tencent-examples/polaris-quickstart-example/src/main/java/com/tencent/cloud/polaris/quickstart/example/EchoService.java
rename to spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoServer.java
index 27a25b63..3965f046 100644
--- a/spring-cloud-tencent-examples/polaris-quickstart-example/src/main/java/com/tencent/cloud/polaris/quickstart/example/EchoService.java
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoServer.java
@@ -15,15 +15,15 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.polaris.quickstart.example;
+package com.tencent.cloud.polaris.quickstart.consumer;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
-@FeignClient(value = "EchoService")
-public interface EchoService {
+@FeignClient(value = "EchoServer")
+public interface EchoServer {
@GetMapping("/quickstart/echo")
- String echo(@RequestParam("msg") String msg);
+ String echo(@RequestParam("value") String value);
}
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/bootstrap.yml
new file mode 100644
index 00000000..99d00fbb
--- /dev/null
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/bootstrap.yml
@@ -0,0 +1,8 @@
+server:
+ port: 0
+spring:
+ application:
+ name: EchoClient
+ cloud:
+ polaris:
+ address: grpc://127.0.0.1:8091
\ No newline at end of file
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/src/main/resources/log4j.properties b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/log4j.properties
similarity index 100%
rename from spring-cloud-tencent-examples/polaris-quickstart-example/src/main/resources/log4j.properties
rename to spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/log4j.properties
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/src/main/resources/logback-spring.xml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/logback-spring.xml
similarity index 100%
rename from spring-cloud-tencent-examples/polaris-quickstart-example/src/main/resources/logback-spring.xml
rename to spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/logback-spring.xml
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/pom.xml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/pom.xml
new file mode 100644
index 00000000..f4f1b628
--- /dev/null
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/pom.xml
@@ -0,0 +1,34 @@
+
+
+
+ polaris-quickstart-example
+ com.tencent.cloud
+ ${revision}
+ ../pom.xml
+
+ 4.0.0
+
+ quickstart-provider
+
+
+
+ spring-cloud-starter-tencent-polaris-discovery
+ com.tencent.cloud
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
\ No newline at end of file
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerApplication.java b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerApplication.java
new file mode 100644
index 00000000..1f0dbefe
--- /dev/null
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerApplication.java
@@ -0,0 +1,29 @@
+/*
+ * Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
+ *
+ * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
+ *
+ * Licensed under the BSD 3-Clause License (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://opensource.org/licenses/BSD-3-Clause
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+package com.tencent.cloud.polaris.quickstart.provider;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class EchoServerApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(EchoServerApplication.class, args);
+ }
+}
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerController.java b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerController.java
new file mode 100644
index 00000000..093ae1a7
--- /dev/null
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerController.java
@@ -0,0 +1,37 @@
+/*
+ * Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
+ *
+ * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
+ *
+ * Licensed under the BSD 3-Clause License (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://opensource.org/licenses/BSD-3-Clause
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed
+ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+package com.tencent.cloud.polaris.quickstart.provider;
+
+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;
+
+/**
+ * main http controller for EchoService
+ */
+@RestController
+@RequestMapping("/quickstart")
+public class EchoServerController {
+
+ @GetMapping("/echo")
+ public String echo(@RequestParam(value = "value") String value) {
+ return "echo: " + value;
+ }
+
+}
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/bootstrap.yml
new file mode 100644
index 00000000..c4bfa75b
--- /dev/null
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/bootstrap.yml
@@ -0,0 +1,8 @@
+server:
+ port: 0
+spring:
+ application:
+ name: EchoServer
+ cloud:
+ polaris:
+ address: grpc://127.0.0.1:8091
\ No newline at end of file
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/log4j.properties b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/log4j.properties
new file mode 100644
index 00000000..9e520cb7
--- /dev/null
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/log4j.properties
@@ -0,0 +1,15 @@
+log4j.rootLogger=DEBUG,console,FILE
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.threshold=INFO
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n
+
+log4j.appender.FILE=org.apache.log4j.RollingFileAppender
+log4j.appender.FILE.Append=true
+
+log4j.appender.FILE.File=applog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
+log4j.appender.FILE.Threshold=INFO
+log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n
+log4j.appender.FILE.MaxFileSize=10MB
\ No newline at end of file
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/logback-spring.xml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/logback-spring.xml
new file mode 100644
index 00000000..57f025c4
--- /dev/null
+++ b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/logback-spring.xml
@@ -0,0 +1,31 @@
+
+
+ logback
+
+
+
+ %d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+ true
+
+
+ applog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
+
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss} -%msg%n
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-quickstart-example/src/main/resources/bootstrap.yml
deleted file mode 100644
index 0b6e763d..00000000
--- a/spring-cloud-tencent-examples/polaris-quickstart-example/src/main/resources/bootstrap.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-server:
- session-timeout: 1800
- port: 47080
-spring:
- application:
- name: EchoService
- cloud:
- polaris:
- address: grpc://127.0.0.1:8091
\ No newline at end of file