WillemJiang closed pull request #621: [SCB-434] fix jaxrs-provider sample
dependency
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/621
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/samples/jaxrs-sample/README.md b/samples/jaxrs-sample/README.md
index f8042776a..25dad6cbe 100644
--- a/samples/jaxrs-sample/README.md
+++ b/samples/jaxrs-sample/README.md
@@ -64,4 +64,5 @@ To consume a provider-service, only need to decalare a member
of a service API t
On the consumer side, you can see the following outputs if the consumer can
invoke the producer:
1. *'Hello Java Chassis'* means the consumer calls sayhi by RpcReference
successfully
- 2. *'Hello person ServiceComb/Java Chassis'* means the consumer calls
sayhello by RpcReference successfully
\ No newline at end of file
+ 2. *'Hello person ServiceComb/Java Chassis'* means the consumer calls
sayhello by RpcReference successfully
+ 3. *'Bye !'* means the consumer calls saybye by RestTemplate successfully
\ No newline at end of file
diff --git a/samples/jaxrs-sample/jaxrs-consumer/pom.xml
b/samples/jaxrs-sample/jaxrs-consumer/pom.xml
index aa33ab4eb..9aae2befa 100644
--- a/samples/jaxrs-sample/jaxrs-consumer/pom.xml
+++ b/samples/jaxrs-sample/jaxrs-consumer/pom.xml
@@ -50,6 +50,10 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>provider-pojo</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>provider-springmvc</artifactId>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
diff --git
a/samples/jaxrs-sample/jaxrs-consumer/src/main/java/org/apache/servicecomb/samples/jaxrs/consumer/JaxrsConsumerMain.java
b/samples/jaxrs-sample/jaxrs-consumer/src/main/java/org/apache/servicecomb/samples/jaxrs/consumer/JaxrsConsumerMain.java
index 7fa2ed4c3..67bcab523 100644
---
a/samples/jaxrs-sample/jaxrs-consumer/src/main/java/org/apache/servicecomb/samples/jaxrs/consumer/JaxrsConsumerMain.java
+++
b/samples/jaxrs-sample/jaxrs-consumer/src/main/java/org/apache/servicecomb/samples/jaxrs/consumer/JaxrsConsumerMain.java
@@ -19,9 +19,11 @@
import org.apache.servicecomb.foundation.common.utils.BeanUtils;
import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
import org.apache.servicecomb.samples.common.schema.Hello;
import org.apache.servicecomb.samples.common.schema.models.Person;
import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
@Component
public class JaxrsConsumerMain {
@@ -35,6 +37,10 @@ public static void main(String[] args) throws Exception {
Person person = new Person();
person.setName("ServiceComb/Java Chassis");
System.out.println(hello.sayHello(person));
+
+ RestTemplate restTemplate = RestTemplateBuilder.create();
+ String result = restTemplate.getForObject("cse://jaxrs/jaxrshello/saybye",
String.class);
+ System.out.println(result);
}
public static void init() throws Exception {
diff --git a/samples/jaxrs-sample/jaxrs-provider/pom.xml
b/samples/jaxrs-sample/jaxrs-provider/pom.xml
index c048012fd..b85065560 100644
--- a/samples/jaxrs-sample/jaxrs-provider/pom.xml
+++ b/samples/jaxrs-sample/jaxrs-provider/pom.xml
@@ -48,7 +48,7 @@
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
- <artifactId>provider-rest-common</artifactId>
+ <artifactId>provider-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git
a/samples/jaxrs-sample/jaxrs-provider/src/main/java/org/apache/servicecomb/samples/jaxrs/provider/JaxrsHelloImpl.java
b/samples/jaxrs-sample/jaxrs-provider/src/main/java/org/apache/servicecomb/samples/jaxrs/provider/JaxrsHelloImpl.java
index 3bb0e5a21..f2cf33265 100644
---
a/samples/jaxrs-sample/jaxrs-provider/src/main/java/org/apache/servicecomb/samples/jaxrs/provider/JaxrsHelloImpl.java
+++
b/samples/jaxrs-sample/jaxrs-provider/src/main/java/org/apache/servicecomb/samples/jaxrs/provider/JaxrsHelloImpl.java
@@ -18,6 +18,7 @@
package org.apache.servicecomb.samples.jaxrs.provider;
+import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@@ -45,4 +46,11 @@ public String sayHi(String name) {
public String sayHello(Person person) {
return "Hello person " + person.getName();
}
+
+ @Path("/saybye")
+ @GET
+ public String sayBye() {
+ return "Bye !";
+ }
+
}
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services