Annotation Type Component


Identify a bean as component with singleton scope that avaje-inject will use.

This is an alternative to using the standard @Singleton annotation. We generally use @Component when we:

  • Want to use avaje-inject in a project that has some other library using @Singleton
  • Want to support BOTH javax.inject and jakarta.inject

Example



 @Component
 class MyEmailSender implements EmailSender {

   ...
 }
 

Ignoring @Singleton

Set InjectModule.ignoreSingleton() true to get avaje-inject to ignore classes annotated with @Singleton. Typically, we want another DI library to use those classes and want avaje-inject to co-exist independently.



   @InjectModule(name = "coffee", ignoreSingleton = true)
   package coffee;

   import io.avaje.inject.InjectModule;

 
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    Specify types to generate DI classes for.