Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guice @Nullable annotation

In my service, I have a protected constructor with @Inject and one of the parameters (provider) @Nullable. Any ideas why I am getting

com.google.inject.CreationException: Guice creation errors:
1) No implementation for [[service]] was bound.

? Guice is 3.0pre1, @Nullable is ours.

like image 345
seminolas Avatar asked Feb 26 '23 05:02

seminolas


1 Answers

@Nullable isn't the same as @Inject(optional=true)... I think if you want to inject null, you need to bind(Service.class).toProvider(Providers.<Service>of(null)) or to otherwise have some kind of provider bound that may return null.

like image 85
ColinD Avatar answered Mar 11 '23 20:03

ColinD