Rest

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestTemplateConfig {


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


}
    @Autowired
    RestTemplate restTemplate;

    @GetMapping("/test")
    public String get(){
        return restTemplate.getForObject("http://127.0.0.1:10000/get/test", String.class); // String.class 返回类型
    }

 

posted @ 2020-10-17 23:23  Cxvvy  阅读(48)  评论(0编辑  收藏  举报