Guice @Nullable annotation

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

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

? Guice - 3.0pre1, @Nullable is ours.

+4
source share
1 answer

@Nullable is not the same as @Inject(optional=true) ... I think if you want to insert null you need bind(Service.class).toProvider(Providers.<Service>of(null)) or else have some provider binding that can return null .

+7
source

Source: https://habr.com/ru/post/1338263/


All Articles