5
匕首2静态注射的任何示例。我已经尝试过这样的: -匕首2静态注射
class A{
@Inject
static B b;
static {
getAppInstance().getComponent().inject(A.class);
}
static anyMethod(){
b.anotherMethod();
}
}
public interface AppComponent{
void inject(Class<A> aClass);
}
为什么你需要它是静态的?单身人士提供者应该达到你所需要的。 – davehenry
@davehenry您可能希望它是静态的,因此可以使用静态方法。 –