spring:http和dubbo请求

http请求

maven依赖


    org.springframework.cloud
    spring-cloud-starter-openfeign

application.yaml配置连接

userfoot.url: http://recsys.bigdata.api

Fegin连接
name:指定FeignClient的名称,name属性会作为微服务的名称,用于服务发现
url:url一般用于调试,可以手动指定@FeignClient调用的地址
path:定义当前FeignClient的统一前缀

FeignClient接口,不能使用@GettingMapping 之类的组合注解
FeignClient接口中,如果使用到@PathVariable ,必须指定其value

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(url = "${userfoot.url}", name = "member-view-history", path = "/history")
public interface UserFootClient {

    @RequestMapping(method = RequestMethod.GET)
    RetUserFoot getHistory(@RequestParam("uid") String uid, @RequestParam("area") String area, @RequestParam("imageSize") String imageSize,
                           @RequestParam("currentPage") Integer currentPage, @RequestParam("pageSize") Integer pageSize, @RequestParam("isCustom") boolean isCustom);

}

dubbo请求

maven依赖


   com.alibaba.boot
    dubbo-spring-boot-starter
    ${dubbo.spring.boot.version}


    com.gome.rec
    bigdata-footprint
    1.0-SNAPSHOT

Java客户端

@Reference
private FootprintService footprintService;

Java服务端

@Service(
        version = "${dubbo.service.version}",
        application = "${dubbo.application.id}",
        protocol = "${dubbo.protocol.id}",
        registry = "${dubbo.registry.id}"
)

你可能感兴趣的:(●项目之旅)