Tying in Guice without

My question is: Usually in Guice I use bind (classe) .to (another_class_Implementation) ...

However, I found in the source code that they used only bind (class) (without the ".to (another_class_Implementation)" part) ...

What does it mean (bind (class) without "to or as")?

Here is the piece of code in question:

public class RestModule extends AbstractModule {

    @Override
    protected void configure() {

        bind(RootResource.class);
        bind(DeveloperUtilsRedirector.class);

        bind(M34Repository.class).to(M34RepositoryImpl.class);
        bind(IGARepository.class).to(IGARepositoryImpl.class);

Answers are welcome

+4
source share
1 answer

bindthe expression without tois called Non-Target Binding (a typo, like "non-target bindings" on the wiki URL) in the Guice documentation. On this wiki page:

. , @ImplementedBy @ProvidedBy. [sic] , .

Guice :

  1. .

    Guice , (, A), , , @Inject -annotated -arg. , Guice Just-In-Time ( " "). ( A A, A B, B C ..), .

    , Guice , .

  2. Guice , , , @ImplementedBy @ProvidedBy ( getInstance injectMembers). Guice , . , , Guice , (1), , . , getInstance injectMembers ; , .

  3. , requireExplicitBindings. , , . .

+9

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


All Articles