I am receiving this error and I am not sure why I thought I instantiated my beans correctly.
public class HttpDataService implements DataService { private final static Logger LOGGER = LoggerFactory.getLogger(HttpDataService.class); private final RestTemplate restTemplate; private final ObjectMapper objectMapper = new ObjectMapper(); public HttpDataService(RestTemplate restTemplate) { this.restTemplate = restTemplate; } @Override public Optional<DataResponse> getData(String bookId, Brand brand) {}
And here is mu Application.class where I have
@Bean public BookIdResolver bookIdResolver(DataService dataService) { return new BookIdResolver(bookDataService); }
What am I missing?
Advertisement
Answer
You are missing the Bean for DataService
@Bean public RestTemplate getRestTemplate() { return new RestTemplate(); } @Bean public DataService getDataService() { return new HttpDataService(getRestTemplate()); }