Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Spring with Hibernate Data-Driven Application Design Add a service for Contact objects

Jeremiah Shore
Jeremiah Shore
31,168 Points

Add a service for Contact objects, task 2 not passing

As far as I can tell, I have everything I need to include an AutoWired ContactDao object so that I can call and return its findById(Long id) method from within my service's method of the same name. What am I missing?

I keep getting "Could not find an autowired ContactDao" as my error message.

com/teamtreehouse/contactmgr/service/ContactService.java
package com.teamtreehouse.contactmgr.service;

import com.teamtreehouse.contactmgr.model.Contact;

public interface ContactService {
  Contact findById(Long id);
}
com/teamtreehouse/contactmgr/service/ContactServiceImpl.java
package com.teamtreehouse.contactmgr.service;

import com.teamtreehouse.contactmgr.dao.ContactDao;
import com.teamtreehouse.contactmgr.model.Contact;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ContactServiceImpl implements ContactService {

  @AutoWired
  private ContactDao contactDao;

  @Override
  public Contact findById(Long id) {
    return contactDao.findById(id);
  }

}

1 Answer

Jeremiah Shore
Jeremiah Shore
31,168 Points

It was the capitalized W in my @AutoWired annotation... it should be @Autowired LOL

Anyone else think this is a poor naming choice? I know this has hit me in the past, but luckily IntelliJ catches it for me, unlike these code challenges :P