测试请求

测试 Dubbo 调用

TestService 中下断点,并通过浏览器访问 http://localhost:10201/test ,由下图可以看出此时我们是通过 Dubbo 进行服务调用

浏览器会输出

Hi Spring Cloud Alibaba Dubbo
1

测试 RESTful 调用

spring-cloud-alibaba-dubbo-consumer-service 项目中排除 Dubbo 相关依赖,POM 修改如下

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.funtl</groupId>
        <artifactId>spring-cloud-alibaba-dubbo-consumer</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>

    <artifactId>spring-cloud-alibaba-dubbo-consumer-service</artifactId>
    <url>http://www.funtl.com</url>

    <dependencies>
        <dependency>
            <groupId>com.funtl</groupId>
            <artifactId>spring-cloud-alibaba-dubbo-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.funtl</groupId>
                    <artifactId>spring-cloud-alibaba-dubbo-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.alibaba.boot</groupId>
                    <artifactId>dubbo-spring-boot-starter</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.funtl</groupId>
            <artifactId>spring-cloud-alibaba-dubbo-provider-api</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
    </dependencies>

</project>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

TestService 中下断点,并通过浏览器访问 http://localhost:10201/test ,由下图可以看出此时我们是通过 HTTP 进行服务调用

浏览器会输出

Hi Spring Cloud Alibaba Dubbo
1
上次更新: 2019-3-16 10:19:40