Time for action – creating a repository object
Perform the following steps to create a repository class to access your product domain objects:
- Create an interface called
ProductRepository
under the packagecom.packt.webstore.domain.repository
in the source foldersrc/main/java
. Add a single method declaration in it, as follows:List <Product> getAllProducts();
- Create a class called
InMemoryProductRepository
under the packagecom.packt.webstore.domain.repository.impl
in the source foldersrc/main/java
. Now, add the following code into it:package com.packt.webstore.domain.repository.impl; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import org.springframework.stereotype.Repository; import com.packt.webstore.domain.Product; ...
Get Spring MVC Beginner’s Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.