I want to start using Guice 3.x to magically enter my instances java.util.logging.Logger.
Here is the code snippet I'm trying to find:
@Singleton
public class Main
{
@Inject
private static final Logger logger;
...
}
This does not work.
I get Exception in thread "main" java.lang.NullPointerExceptionno matter what area I use in the ad.
I added a line super.requestStaticInjection(Main.class);to mine modulein the method configure()and started working, but only if I delete the keyword finaland make it static Logger logger.
I would rather leave Logger final, if at all possible.
What is the correct idiomatic way for Guice to do this?
source
share