guice injection in static variable
问题 I Have doubt about guice injection. Is it possible to inject a @named variable value to a static variable? I have tried @Provides @Named("emp.id") public Integer getEmpId() { return 2; } and tried to inject this value to static variable such as @Inject @Named("emp.id") private static Integer id; But the id return value null, When I removed static modifier the id gave value 1. What is really happening here? 回答1: Guice does not inject static fields by design. You can request static injection