Help with @Inject, for some reason it doesn't work.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
I have a class i wan't inject
For legacy code support it is like this.
```
@Singleton
public class Applications extends AbstractModule {
private Applications() {}
private static class ApplicationsLoader {
static final Applications INSTANCE = new Applications();
}
@Override protected void configure() {}
@Provides @Singleton
public Applications get() {
return ApplicationsLoader.INSTANCE;
}
public static Applications getApps() {
return ApplicationsLoader.INSTANCE;
}
}
```
On application startup , I create injector.
```
public void startup() throws Exception {
initLogging();
Injector injector = Guice.createInjector(Stage.PRODUCTION, Applications.getApps());
}
```
but some while after, when I need Applications.class i always get a null
```
public class Blob {
@Inject private Applications applications;
.....
}
```
Any suggestions how to share Applications.class singleton?
injector.getInstance(Applications.class) working fine.
Regards
Contributor guide
Assessment
This issue has not been assessed yet.