Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class DemoApplication implements CommandLineRunner {
public static void main(String[] args) {, args);
private final RestTemplate restTemplate;
// RestTemplateをコンストラクタインジェクションする
public DemoApplication(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
public void run(String... args) {
// REST APIにGETでリクエストする
// 第一引数:URL、第二引数:レスポンスの型
Quote response = restTemplate.getForObject("", Quote.class);
System.out.println(response.toString()); // Quote{type='success', value=Value{id=1, quote='Working with Spring Boot is like pair-programming with the Spring developers.'}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.