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

Hannah Lee
Hannah Lee
80,187 Points

Add a service interface and implementing class in their respective files. Include a findById method that accepts a Long

I'm stuck in this session...please help me...

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

import com.teamtreehouse.contactmgr.model.Contact;
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
private CategoryService category Service{

    @Override
        public interface Category{
        Category findByID(Long id);
    return null;
        }
}

1 Answer

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,703 Points

The “Preview” button will let you see the compiler errors. Here’s the first error I get when I ran your code:

com.github.javaparser.ParseException: Encountered "  "CategoryService "" at line 10, column 9.
Was expecting one of:
    "class" ...
    "enum" ...
    "interface" ...

This is what we have on line 10 of ContactServiceImpl.java

private CategoryService category Service {

So it’s seeing CategoryService and was expecting some other keyword like class, enum, interface. In this case, I think it should be class. What we want to do here is define an interface in ContactService.java and a class that implements that interface in ContactServiceImpl.java

The best video for you to reference for this is a couple steps back here.

Let me know if you have more questions.