依赖
xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
<relativePath/>
</parent>
<properties>
<java.version>1.8</java.version>
<dubbo.version>2.7.23</dubbo.version>
</properties>
<dependencies>
<!-- Spring Boot Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Dubbo Spring Boot Starter -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${dubbo.version}</version>
</dependency>
问题1:20880端口没有监听
解决1:registry-address: N/A
application.yml
dubbo:
protocol:
name: dubbo
port: 20880
registry:
address: N/A # 不使用注册中心,直连提供者
问题2:没有进行序列化和反序列化
解决2: @DubboReference中 injvm= false // 禁用 In-JVM
// 关键:使用 url 指定直连地址
@DubboReference(
url = "dubbo://127.0.0.1:20880/com.wc88.dubbo.service.GreetingService",
check = false, // 启动时不检查
injvm= false
) // Dubbo 的 @Reference