You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/05/04 11:24:23 UTC

[GitHub] zhengyangyong closed pull request #76: Add Notes for providers and fix FAQ mistakes

zhengyangyong closed pull request #76: Add Notes for providers and fix FAQ mistakes
URL: https://github.com/apache/incubator-servicecomb-website/pull/76
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/_faqs/cn/faq.md b/_faqs/cn/faq.md
index 43533c4..b862864 100755
--- a/_faqs/cn/faq.md
+++ b/_faqs/cn/faq.md
@@ -50,29 +50,13 @@ redirect_from:
 
    A: 可以,具体可以参考java-chassis的[integration-test的实现](https://github.com/apache/incubator-servicecomb-java-chassis/blob/master/integration-tests/springmvc-tests/src/test/java/org/apache/servicecomb/demo/springmvc/tests/SpringMvcIntegrationTestBase.java)。
 
-* **Q: 微服务启动后,无法正确调用接口,使用的代码为:**
+* **Q: 微服务启动后,无法正确调用接口,或返回不存在错误?**
 
-   ```java
-   @RestController
-   @RestSchema(schemaId = "worker")
-   public class WorkerController {
-     @RequestMapping(value="/count", method=RequestMethod.GET)
-     public int getWorkerNumbers() {
-       ...
-     }
-   }
-   ```
-
-   A: 在没有指明根路径的情况下,默认会使用类名作为其根路径,即上述代码中可访问的路径应为`/WorkerController/count`。如果想要实现`/count`这样的访问,则要指明根路径:
-
-   ```java
-   @RequestMapping(value = "/")
-   public class WorkerController {}
-   ```
-
-* **Q: 如果没有指定RequestMapping这个标注的value时,默认的基本路径是什么?**
-
-   A: 假设你的Controller类名为*HelloController*,那么基本路径就是/HelloController。
+   A: 请检查调用路径与Producer实现代码中发布的路径完全一致。Producer端的启动日志可以查看到映射路径输出,例如:
+   
+   `[INFO] Swagger mapped "{[/hello/], method=[GET], produces=[application/json]}"`
+   
+   不同编程风格(模型)实现Producer的文档和注意事项请参见:[Jaxrs](/cn/users/develop-with-jax-rs/) [SpringMVC](/cn/users/develop-with-springmvc/) [Pojo](/cn/users/develop-with-transparent-rpc/) [Spring Boot](/cn/users/develop-with-spring-boot-starter/) 。
 
 * **Q: 在eclipse下修改了microservice.yaml配置文件下的端口号,启动程序后,端口号没生效?**
 
diff --git a/_posts/cn/2018-04-28-saga_with_cucumber.md b/_posts/cn/2018-04-28-saga_with_cucumber.md
index 71d88cd..755dbb6 100644
--- a/_posts/cn/2018-04-28-saga_with_cucumber.md
+++ b/_posts/cn/2018-04-28-saga_with_cucumber.md
@@ -6,7 +6,7 @@ permalink: /cn/docs/saga_with_cucumber/
 excerpt: "ServiceComb Saga使用Cucumber做验收测试源码分析"
 last_modified_at: 2018-04-27T19:05:00+08:00
 author: Li Bo
-tags: [Saga Cucumber]
+tags: [Saga, Cucumber]
 redirect_from:
   - /theme-setup/
 ---
@@ -323,4 +323,4 @@ Saga在Cucumber中集成了byteman注入一个超时异常,测试Saga对超时
 
 [6] debug 分支 https://github.com/lijasonvip/incubator-servicecomb-saga/tree/debug-cucumber-byteman
 
-[7] 加入ServiceComb 社区  http://servicecomb.incubator.apache.org/cn/docs/join_the_community/
\ No newline at end of file
+[7] 加入ServiceComb 社区  http://servicecomb.incubator.apache.org/cn/docs/join_the_community/
diff --git a/_users/cn/develop-with-jax-rs.md b/_users/cn/develop-with-jax-rs.md
index 9314031..8ae792f 100644
--- a/_users/cn/develop-with-jax-rs.md
+++ b/_users/cn/develop-with-jax-rs.md
@@ -80,6 +80,10 @@ ServiceComb支持开发者使用JAX-RS注解,使用JAX-RS模式开发服务。
      }
    }
    ```
+   
+   **注意:请一定在服务的实现类(本文档例子为JaxrsHelloImpl)上标记@Path,否则接口发布的Path和Method将会不正确!**
+   
+   本例sayHi的访问Path为`/jaxrshello/sayhi`,sayHello的访问Path为`/jaxrshello/sayhello`,如果希望他们的访问路径为`/sayhi`和`/sayhello`,直接设置JaxrsHelloImpl上的`@Path`为`@Path("/")`。
 
 * **步骤 3** 发布服务。
 
diff --git a/_users/cn/develop-with-springboot-starter.md b/_users/cn/develop-with-springboot-starter.md
index b4d33e1..ecfb556 100644
--- a/_users/cn/develop-with-springboot-starter.md
+++ b/_users/cn/develop-with-springboot-starter.md
@@ -76,6 +76,10 @@ Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来
     }
    }
    ```
+   
+   **注意:请一定在服务的实现类(本文档例子为SpringmvcHelloImpl)上标记@RequestMapping,否则接口发布的Path和Method将会不正确!**
+         
+   本例sayHi的访问Path为`/springmvchello/sayhi`,sayHello的访问Path为`/springmvchello/sayhello`,如果希望他们的访问路径为`/sayhi`和`/sayhello`,直接设置SpringmvcHelloImpl上的`@RequestMapping`为`@RequestMapping(path = "/")`。
 
 * **步骤 3** 发布服务
 
diff --git a/_users/cn/develop-with-springmvc.md b/_users/cn/develop-with-springmvc.md
index 9a1c94f..d422b7f 100644
--- a/_users/cn/develop-with-springmvc.md
+++ b/_users/cn/develop-with-springmvc.md
@@ -77,6 +77,10 @@ ServiceComb支持SpringMVC注解,允许使用SpringMVC风格开发微服务。
     }
    }
    ```
+   
+   **注意:请一定在服务的实现类(本文档例子为SpringmvcHelloImpl)上标记@RequestMapping,否则接口发布的Path和Method将会不正确!**
+      
+   本例sayHi的访问Path为`/springmvchello/sayhi`,sayHello的访问Path为`/springmvchello/sayhello`,如果希望他们的访问路径为`/sayhi`和`/sayhello`,直接设置SpringmvcHelloImpl上的`@RequestMapping`为`@RequestMapping(path = "/")`。
 
 * **步骤 3** 发布服务
 
diff --git a/_users/cn/develop-with-transparent-rpc.md b/_users/cn/develop-with-transparent-rpc.md
index ac0f2b8..8b6add4 100644
--- a/_users/cn/develop-with-transparent-rpc.md
+++ b/_users/cn/develop-with-transparent-rpc.md
@@ -109,10 +109,17 @@ redirect_from:
 
    ```java
    import org.apache.servicecomb.provider.pojo.RpcSchema;
-   // other code omitted
    @RpcSchema(schemaId = "pojoHello")
    public class HelloImpl implements Hello {
-     // other code omitted
+      @Override
+      public String sayHi(String name) {
+        return "Hello " + name;
+      }
+ 
+      @Override
+      public String sayHello(Person person) {
+        return "Hello person " + person.getName();
+      }
    }
    ```
 
@@ -130,6 +137,10 @@ redirect_from:
    </beans>
    ```
 
+**注意:无论哪种发布模式,rest发布的URL都为`ClassName/MethodName`,并且Method都为`POST`。**
+         
+本例sayHi的访问Path为`/HelloImpl/sayHi`,sayHello的访问Path为`/HelloImpl/sayHello`。
+
 > **说明**:
 与Spring MVC开发模式和JAX-RS开发模式不同的是,透明RPC开发模式使用的注解是`@RpcSchema`而非`@RestSchema`。
 
diff --git a/_users/develop-with-jax-rs.md b/_users/develop-with-jax-rs.md
index 95849a4..ef63847 100644
--- a/_users/develop-with-jax-rs.md
+++ b/_users/develop-with-jax-rs.md
@@ -77,6 +77,10 @@ ServiceComb supports developers in developing services in JAX-RS mode by using J
      }
    }
    ```
+   
+   **Note: PLEASE MAKE SURE TO MARK @Path ON YOUR PRODUCER(JaxrsHelloImpl), OR THE PATH AND METHOD OF PUBLISHED WILL BE INCORRECT!**
+   
+   In this sample the Path of sayHi is `/jaxrshello/sayhi`, and the Path of sayHello is `/jaxrshello/sayhello`, if you wish them `/sayhi` and `/sayhello`, please change the setting of `@Path` on the JaxrsHelloImpl to `@Path("/")`.
 
 * **Step 3** Release the service. Add ```@RestSchema``` as the annotation of the service implementation class and specify schemaID, which indicates that the implementation is released as a schema of the current microservice. The code is as follows:
 
diff --git a/_users/develop-with-springboot-starter.md b/_users/develop-with-springboot-starter.md
index 85c9ebb..50a285b 100644
--- a/_users/develop-with-springboot-starter.md
+++ b/_users/develop-with-springboot-starter.md
@@ -71,6 +71,10 @@ You need to use the native Java Chassis framework to develop microservice applic
     }
    }
    ```
+   
+   **Note: PLEASE MAKE SURE TO MARK @Path ON YOUR PRODUCER(SpringmvcHelloImpl), OR THE PATH AND METHOD OF PUBLISHED WILL BE INCORRECT!**
+   
+   In this sample the Path of sayHi is `/springmvchello/sayhi`, and the Path of sayHello is `/springmvchello/sayhello`, if you wish them `/sayhi` and `/sayhello`, please change the setting of `@Path` on the SpringmvcHelloImpl to `@Path("/")`.
 
 * **Step 3** Release the service. Add @RestSchema as the annotation of the service implementation class and specify schemaId, which indicates that the implementation is released as a schema of the current microservice. The code is as follows:
 
diff --git a/_users/develop-with-springmvc.md b/_users/develop-with-springmvc.md
index 900b89f..2b17fe2 100644
--- a/_users/develop-with-springmvc.md
+++ b/_users/develop-with-springmvc.md
@@ -74,6 +74,10 @@ ServiceComb supports Spring MVC remark and allows you to develop microservices i
     }
    }
    ```
+   
+   **Note: PLEASE MAKE SURE TO MARK @Path ON YOUR PRODUCER(SpringmvcHelloImpl), OR THE PATH AND METHOD OF PUBLISHED WILL BE INCORRECT!**
+   
+   In this sample the Path of sayHi is `/springmvchello/sayhi`, and the Path of sayHello is `/springmvchello/sayhello`, if you wish them `/sayhi` and `/sayhello`, please change the setting of `@Path` on the SpringmvcHelloImpl to `@Path("/")`.
 
 * **Step 3** Release the service. Add @RestSchema as the annotation of the service implementation class and specify schemaId, which indicates that the implementation is released as a schema of the current microservice. The code is as follows:
 
diff --git a/_users/develop-with-transparent-rpc.md b/_users/develop-with-transparent-rpc.md
index 9a80e4a..a9f95bb 100644
--- a/_users/develop-with-transparent-rpc.md
+++ b/_users/develop-with-transparent-rpc.md
@@ -101,10 +101,17 @@ The transparent remote procedure call(RPC) development mode is a development mod
 
    ```java
    import org.apache.servicecomb.provider.pojo.RpcSchema;
-   // other code omitted
    @RpcSchema(schemaId = "pojoHello")
    public class HelloImpl implements Hello {
-     // other code omitted
+      @Override
+      public String sayHi(String name) {
+        return "Hello " + name;
+      }
+ 
+      @Override
+      public String sayHello(Person person) {
+        return "Hello person " + person.getName();
+      }
    }
    ```
 
@@ -122,6 +129,10 @@ The transparent remote procedure call(RPC) development mode is a development mod
    </beans>
    ```
 
+**Note: THE PATH FOR REST IS `ClassName/MethodName`, AND THE METHOD IS `POST`.**
+
+In this sample the Path of sayHi is `/HelloImpl/sayHi`, and the Path of sayHello is `/HelloImpl/sayHello`.
+
 > **NOTE**:
 Different from the Spring MVC and JAX-RS development modes, the transparent RPC development mode used `@RpcSchema` instead of `@RestSchema`.
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services