Service dependencies

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

Get Building Serverless Architectures 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.