在模块类中,我们是否需要@Inject overprovids___方法? 例如。
@Singleton
@Provides
@Inject
A provideA(ExampleClass1<B> example1, ExampleClass2 example2) {
return new A(example1, example2);
}
@Provides
@Singleton
@Inject
B provideB(A a) {
return new B(new C(a));
}
在此示例中,我需要@Inject吗?
答案 0 :(得分:1)
不。 @Provides
方法不需要@Inject
批注。 @Provides
方法的参数已经自动注入。