https://github.com/vnt-dev/myrpc
一个RPC框架
https://github.com/vnt-dev/myrpc
Last synced: 11 months ago
JSON representation
一个RPC框架
- Host: GitHub
- URL: https://github.com/vnt-dev/myrpc
- Owner: vnt-dev
- Created: 2020-03-01T03:32:21.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-26T22:15:43.000Z (almost 3 years ago)
- Last Synced: 2025-04-30T15:42:33.919Z (11 months ago)
- Language: Java
- Size: 186 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MyRPC
一个RPC框架
## 使用方式:
1.编译代码 mvn install到本地maven仓库
2.构建springboot工程,在pom文件中加入依赖
```
com.wherewego
my-rpc
0.0.1-alpha
```
3.添加配置信息
```
#配置目标服务的地址
wherewego.rpc.address=127.0.0.1:8088
#配置服务提供者的端口号(如果当前的工程不是服务提供者,则可以不配置)
wherewego.rpc.protocol.port=8088
#通信协议
wherewego.rpc.protocol.name=wqRpc
#应用名称
wherewego.rpc.application.name=wqRpc
```
4.服务提供者编写接口
在启动类上加入注解,加入注解MyRPC才能启动
```
//包路径为com.wherewego.rpc.config.annotation
@EnableMyRPC
```
测试代码,例:
```
public interface ITest{
int add(int a,int b);
}
//使用myrpc提供的注解com.wherewego.rpc.config.annotation.MyRPCService
@MyRPCService
public class TestImpl implements ITest{
@Override
public int add(int a,int b){
return a+b;
}
}
```
5.消费者调用服务端接口
在启动类上加入注解,加入注解MyRPC才能启动
```
//包路径为com.wherewego.rpc.config.annotation
@EnableMyRPC
```
测试代码,例:
```
//使用myrpc提供的注解 在com.wherewego.rpc.config.annotation包下
@MyRPCReference
private ITest test;
public void test(){
int sum = test.add(1,2);
System.out.println(sum);
}
```