Skip to content

Parameter 0 of method bookIdResolver in required a bean of type ‘com.bookdata.DataService’ that could not be found

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;

    public Optional<DataResponse> getData(String bookId, Brand brand)  {}

And here is mu Application.class where I have

    public BookIdResolver bookIdResolver(DataService dataService) {
        return new BookIdResolver(bookDataService);

What am I missing?


You are missing the Bean for DataService

   public RestTemplate getRestTemplate() { 
       return new RestTemplate(); 

    public DataService getDataService() {
        return new HttpDataService(getRestTemplate());