O'Reilly logo

Spring MVC Beginner’s Guide by Amuthan G

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating a repository object

Perform the following steps to create a repository class to access your product domain objects:

  1. Create an interface called ProductRepository under the package com.packt.webstore.domain.repository in the source folder src/main/java. Add a single method declaration in it, as follows:
    List <Product> getAllProducts();
  2. Create a class called InMemoryProductRepository under the package com.packt.webstore.domain.repository.impl in the source folder src/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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required