package com.example.spring.bank.account; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.restclient.RestTemplateBuilder; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; @Service public class AccountService { @Value("${rest.baseURL}") private String restBaseURL; private final RestTemplate restTemplate; public AccountService(RestTemplateBuilder restTemplateBuilder) { this.restTemplate = restTemplateBuilder.build(); } public Account getAccount(Integer accno) { return this.restTemplate.getForObject(restBaseURL + "/account/{accno}", Account.class, accno); } }