https://www.wenjiangs.com/doc/dc7xvpxh
https://www.sofastack.tech/projects/sofa-rpc/getting-started-with-rpc/
SOFA Stack 在gitee上的源码仓库
https://gitee.com/sofastack
源码stulab-sofarpc.zip
整合的关键步骤 添加依赖项注意版本号
配制application.propertiescom.alipay.sofa sofaboot-dependencies 2.6.4 com.alipay.sofa sofa-rpc-all 5.5.2 com.alipay.sofa registry-client-all 5.2.0
spring.application.name=service-provider logging.path=./logs com.alipay.sofa.rpc.registry.address=sofa://127.0.0.1:9603 com.alipay.sofa.rpc.bolt.port=12201 server.port=8801发布服务(服务提供方)
import org.springframework.stereotype.Service;
import com.alipay.sofa.runtime.api.annotation.SofaService;
import com.alipay.sofa.runtime.api.annotation.SofaServiceBinding;
import com.stulab.sofarpc.api.HelloService;
@SofaService(interfaceType = HelloService.class,
bindings = { @SofaServiceBinding(bindingType = "bolt") })
@Service
public class HelloServiceImpl implements HelloService{
@Override
public String hello() {
return "Hello World";
}
}
调用服务(服务消息方)
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alipay.sofa.runtime.api.annotation.SofaReference;
import com.alipay.sofa.runtime.api.annotation.SofaReferenceBinding;
import com.stulab.sofarpc.api.HelloService;
@RestController
public class HelloResource {
@SofaReference(interfaceType = HelloService.class, binding = @SofaReferenceBinding(bindingType = "bolt"))
HelloService helloService;
@RequestMapping("/hello")
public String hello() {
return helloService.hello();
}
}
注意点
1、注意SOFA相关依赖的版本,这里面坑挺多
2、发布服务是注意加上@Service注解



