Often, the services we declare have other dependencies. For example, our user service needs a repository service to access the persistence layer. How do we declare these nested dependencies and get the Guice construct to the dependency graph for us?
We can leverage JSR-330 annotations again to declare dependencies for other dependencies. As always, let's look at this in action. Let's start with creating the UserRepository interface in the com.serverlessbook.services.user.repository package:
$ mkdir -p services-user/src/main/java/com/
serverlessbook/services/user/repository
$ touch services-user/src/main/java/com/serverlessbook/
services/user/repository/UserRepository.java
Inside the interface, let's declare the method we need at this stage:
package com.serverlessbook.services.user.repository; import com.serverlessbook.services...