Spring Boot Masterclass – Create service and repository for Expense 06

Hello, in this post we will create Service and Repository for Expense. Let’s begin. First, create an ExpenseRepository under src/main/java/in/bushansirgur/expenseyoutube/repository package

ExpenseRepository.java




@Repository
public interface ExpenseRepository extends JpaRepository<Expense, Long> {

}

Next, create ExpenseSerive and ExpenseServiceImpl under src/main/java/in/bushansirgur/expenseyoutube/service package

ExpenseService.java

public interface ExpenseService {
	
	List<Expense> findAll();
	
}

ExpenseServiceImpl.java

@Service
public class ExpenseServiceImpl implements ExpenseService {

	@Autowired
	ExpenseRepository expenseRepository;
	
	@Override
	public List<Expense> findAll() {
		return expenseRepository.findAll();
	}

}

That’s it for this post, let me know in the comment section if you have any questions on this.

Thanks
Bushan SC

About the author

Bushan Sirgur

Hey guys, I am Bushan Sirgur from Banglore, India. Currently, I am working as an Associate project in an IT company.

View all posts

4 Comments

  • hi sir i am getting error while extending JpaRepository interface.
    *************************
    APPLICATION FAILED TO START
    *************************
    Description:
    A component required a bean named ‘entityManagerFactory’ that could not be found.
    Action:

    Consider defining a bean named ‘entityManagerFactory’ in your configuration.

    Please Answer.
    I have also make a comment on video on youtube.
    Thank You.

Leave a Reply

Your email address will not be published. Required fields are marked *