# dubbo-samples **Repository Path**: OlinOnee/dubbo-samples ## Basic Information - **Project Name**: dubbo-samples - **Description**: 基于 Dubbo 3 实现的生产端和消费端的远程调用示例,支持 IDL(Protobuf)和 Java Interface 两种主流开发对接方式。 - **Primary Language**: Java - **License**: GPL-3.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-10 - **Last Updated**: 2025-07-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # dubbo-samples ## 介绍 基于 **Dubbo 3** 实现的生产端和消费端的远程调用示例,支持 `IDL`(Protobuf)和 `Java Interface` 两种主流开发对接方式。 ## 技术栈 | **技术** | **版本** | |:-----------:|:------:| | JDK | 21 | | Dubbo | 3.3.1 | | Protobuf | 3.19.6 | | Spring Boot | 3.5.0 | ## 代码结构 ```shell dubbo-samples # 项目根目录 ├─dubbo-idl # Dubbo IDL 示例 │ ├─dubbo-idl-customer # IDL 消费端 │ └─dubbo-idl-provider # IDL 生产端 └─dubbo-interface # Dubbo Java Interface 示例 ├─dubbo-interface-api # Java Interface API 模块 ├─dubbo-interface-customer # Java Interface 消费端 └─dubbo-interface-provider # Java Interface 生产端 ``` ## 运行 ### Dubbo IDL 示例 1. 进入 `dubbo-idl-provider` 目录,执行 `mvn clean compile package` 编译(将 `proto` 文件转成 `pojo`)并打包生产端。 2. 进入 `dubbo-idl-customer` 目录,执行 `mvn clean compile package` 编译(将 `proto` 文件转成 `pojo`)并打包消费端。 3. 启动生产端:`java -jar target/dubbo-idl-provider-1.0.0.jar` 4. 启动消费端:`java -jar target/dubbo-idl-customer-1.0.0.jar` ### Dubbo Java Interface 示例 1. 进入 `dubbo-interface-provider` 目录,执行 `mvn clean package` 打包生产端。 2. 进入 `dubbo-interface-customer` 目录,执行 `mvn clean package` 打包消费端。 3. 启动生产端:`java -jar target/dubbo-interface-provider-1.0.0.jar` 4. 启动消费端:`java -jar target/dubbo-interface-customer-1.0.0.jar` ## 验证 ### 创建订单接口 ```bash curl --location --request POST 'http://127.0.0.1:1003/orders' \ --header 'Content-Type: application/json' \ --data-raw '{ "userId": "user123", "items": [ { "productId": "prod1", "productName": "Laptop", "quantity": 1, "price": 1200.0 } ] }' ``` ### 获取订单接口 ```bash curl --location --request GET 'http://127.0.0.1:1003/orders/get?orderId=fd84ca39-55f9-4a00-b251-ca7e78f26f27' ``` ## 参考 - [Dubbo 3 官方文档](https://dubbo.apache.org/zh/docs/) - [Dubbo 3 官方示例仓库](https://github.com/apache/dubbo-samples)