jasonmit
jasonmit

Reputation: 1278

Multi-project dependency injection

Apologies for the vague question, but how is dependency injection typically handled in a multi-project environment? Each module should be able to define its own dependencies and ideally they would be using the same dependency "container".

In the past, in a single project environment, I went about creating a dependency object container where I defined my implicits and then just imported then when I needed a dependency.

Any pointers or tips to point me in the right direction would be helpful.

Upvotes: 1

Views: 93

Answers (1)

Steve B.
Steve B.

Reputation: 57314

This will have to be a bit vague since you don't say anything about what you're using to do your dependency injection, but FWIW, we have a current multi-project mixed scala/java environment injected with guice, so maybe this will be helpful to you.

Since guice allows you to include modules (i.e. nest one module inside another) this allows for hierarchical module structure (they must assume people will use it like this - there's even a grapher included with the distribution to make a nice picture of the relationship between your modules). So, for example, you might have a module that includes database connections and various objects that interact directly with that, and you'd then include that module directly with anything that interacts with the db layer.

Upvotes: 1

Related Questions