u012720534
鲤鱼师兄
采纳率0%
2019-03-27 21:31

怎么通过zookeeper节点获取Dubbo rest协议的服务请求路径呢?

5

dubbo的配置如下

<dubbo:registry address="zookeeper://XXXXXXXXXXX:2181"/>
    <dubbo:protocol name="dubbo" port="20882" />
    <dubbo:protocol name="rest" server="tomcat" port="8002" contextpath="testPath"/>

服务提供者代码:


@Service(version = "${mem.service.version}")
@Path("mem")
public class MemberServiceImpl extends BaseServiceImpl<MemberMapper, Member> implements IMemberService {

    @Override
    @Path("hi")
    @GET
    @Produces({MediaType.TEXT_PLAIN})
    public String sayHi() {
        System.out.println("hi member");
        return "hi member, you get it!";
    }

    @Override
    public Member testGetById(Long id) {
        Member member = new Member();
        member.setName("test");
        member.setId(id);
        return member;
    }
}


zk节点内容:


rest://192.168.1.10:8001/testPath/com.jeomo.mem.service.IMemberService?anyhost=true&application=jeomo-mem&dubbo=2.6.2&generic=false&interface=com.jeomo.mem.service.IMemberService&methods=testGetById,removeById,lambdaQuery,save,removeByMap,update,getObj,saveOrUpdateBatch,sayHi,remove,listByIds,getBaseMapper,removeByIds,updateBatchById,lambdaUpdate,saveOrUpdate,listMaps,saveBatch,query,count,listObjs,list,getMap,updateById,pageMaps,listByMap,getById,getOne,page&pid=329108&revision=1.0.0&server=tomcat&side=provider&timestamp=1553690812928&version=1.0.0

我想要通过zk获取最终的请求路径,即@Path() 注解里的值,比如:
http://192.168.1.10:8001/testPath/mem/hi
该怎么获得 /mem/hi 这个路径。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

相关推荐