```xml
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>thrift-solon-cloud-plugin</artifactId>
</dependency>
```

#### 1、描述

分布式扩展插件。基于 thrift 适配的 rpc 插件。此项目可使用 [Solon Cloud Discovery](/article/369) 插件包，作注册与发现用。

#### 2、配置示例

* pom.xml 增加注册与发现服务包：

来 [Solon Cloud Discovery](/article/369) 选一个插件包。


* 服务端 app.yml 增加 grpc 配置：

```yml
# 服务端声明
server.thrift:
  port: 9090
  name: demo-thrift
```

* 客户端 app.yml 增加 grpc 配置：

```yml
# 客户端本地临时声明（或者使用 solon cloud discovery 服务包的配置）
solon.cloud.local:
  discovery:
    service:
      demo-thrift:
        - "thrift://localhost:9090"
```
    
#### 3、代码应用


* 服务端（实现接口服务）

```java
@ThriftService(serviceName = "UserService")
public class UserServiceImpl implements UserService.Iface {
    @Override
    public User getUser(int id) throws TException {
        User user = new User();
        user.setId(id);
        user.setName("张三");
        user.setAge(18);
        return user;
    }
}
```

* 客户端应用

```java
@Controller
public class TestController {

    @ThriftClient(name = "demo-thrift", serviceName = "UserService")
    private UserService.Client client;

    @Mapping("/test")
    public User test() throws TException {
        return client.getUser(1);
    }
}
```

#### 4、代码演示


[https://gitee.com/noear/solon-examples/tree/main/7.Solon-Remoting-Rpc/demo7016-rpc_thrift](https://gitee.com/noear/solon-examples/tree/main/7.Solon-Remoting-Rpc/demo7016-rpc_thrift)





