普通类的GUICE依赖注入

时间:2020-05-14 17:29:24

标签: java guice

我需要了解如何将对象绑定并注入到普通类中,如下所示:

Exampl1: Want to inject B Obj to the class, here i dont have any constructor.
class A {
 @Inject private B obj;
}

Example2: Want to inject B Obj to class and i have a constructor also.
Class X {
private B obj; 
@Inject public X(int arg1, B obj) {
 this.obj = obj;
}

class Module extends AbstarctModule {
void Configure() {
//How to use bind
}

有人可以帮我吗?

0 个答案:

没有答案