Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,735 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.