开发者

When to provide explicit binding and when to leverage the automatic binding on Guice

I was wonder, why do开发者_JAVA技巧 we need to provide bindings explicitly sometimes and not other times in the module? How does Guice decide when we need the binding and when not?

Is it because if a dependency has no multiple implementations and it is injected elsewhere as a dependencies it will be automatically bound as part of a dependency graph?

Thanks


You need a binding (either through a bind, an @Provides method or an @ImplementedBy annotation) for anything you want injected that is not a concrete class with a no-arg constructor or an @Inject annotated constructor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜