注入一个Bean,即可使用啦!

    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

开始使用 发送GET/POST请求,并将返回值封装成我们需要的对象

    @Autowired
    private RestTemplate restTemplate;

    // 我们知道User使我们需要的返回值,restemplate会自动帮我们处理返回值
    // 模拟Get、Post请求 其中post第二个参数相当于request中body的数据
    @GetMapping("/hello1")
    public void TestHello001(){
        User getforObject = restTemplate.getForObject("https://www.baidu.com", User.class);
        User postforObject = restTemplate.postForObject("https://www.baidu.com",null,User.class);
    }