SpringCloud-Study0001

(一)目前微服务解决方案技术有哪些!

image

(二)SpringCloud的基本组件

image

(三)微服务设置规范

image

使用RestTemplate服务远程调用


/**
 * @description: Rest请求Bean
 * @author: GuoTong
 * @createTime: 2022-03-20 19:08
 * @since JDK 1.8 OR 11
 **/
@Configuration
public class RestClientTemplateConfig {

    /**
     * Description:  快捷Rest请求工具类
     *
     * @author: GuoTong
     * @date: 2022-03-20 19:10:11
     */
    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}

restTemplate调用示例

  ResponseEntity<Resp> remoteCallBackEntity = restTemplate.
                getForEntity("http://localhost:8081",
                Resp.class, userId);
        HttpStatus statusCode = remoteCallBackEntity.getStatusCode();
        if (statusCode.isError()) {}
 	remoteCallBackEntity.getBody();

调用成功

image

posted on 2022-03-20 23:36  白嫖老郭  阅读(23)  评论(0)    收藏  举报

导航