Package io.micronaut.guice.annotation
Annotation Interface Guice
Annotation that can be applied to the application entry point
that allows the import of Guice modules.
Micronaut will import the modules and run them at startup when the application starts registering the provided beans using the Guice DSL.
Note all features of Guice are supported, there exist the following limitations:
- Guice Scopes are not supported
- Guice AOP/Interceptors are not supported
- Guice private modules are not supported
- Static Injection is not supported
- Guice TypeConverters are not supported (use
TypeConverter
instead. - Guice Listeners are not supported (use
BeanCreatedEventListener
instead. - None of the
com.google.inject.spi
API is supported
Note that if you create a runtime binding to a class with LinkedBindingBuilder.to(Class)
that has no injection annotations you may need to import the bean first
to allow the bean to be instantiated without reflection. This can be done with Import
Otherwise it is recommended to as a minimum use the Inject
annotation on the constructor to avoid this need.
-
Required Element Summary
-
Optional Element Summary
-
Element Details
-
modules
Class<? extends com.google.inject.Module>[] modulesImport the given Guice modules.The modules are imported in the order defined by the array.
- Returns:
- An array of module types
-
-
-
classes
Class<?>[] classesImport the given Guice classes.- Returns:
- An array of classes to import
- Default:
- {}
-
classNames
Import the given named Guice classes.- Returns:
- An array of class names to import
- Default:
- {}
-
packages
String[] packagesImport the given packages as guice classes.- Returns:
- An array of package names
- Default:
- {}
-
environments
String[] environmentsThe environment where the modules should be active (Defaults to all environments).- Returns:
- The environments.
- Default:
- {}
-