To solve this problem many frameworks produce runtime metadata or perform expensive reflection to analyze the annotations of a class.

    Micronaut instead produces this annotation metadata at compile time, avoiding expensive reflection and saving on memory.

    The API can be used to obtain a reference to a BeanDefinition which implements the interface.

    For example the following code will obtain all bean definitions annotated with a particular stereotype:

    Lookup Bean Definitions by Stereotype

    The above example will find all BeanDefinition ‘s annotated with regardless whether @Controller is used directly or inherited via an annotation stereotype.

    If you absolutely require a reference to an annotation instance you can use the synthesize method, which will create a runtime proxy that implements the annotation interface:

    Synthesizing Annotation Instances

    This approach is not recommended however, as it requires reflection and increases memory consumption due to the use of runtime created proxies and should be used as a last resort (for example if you need an instance of the annotation to integrate with a third party library).

    There are times when you may want to alias the value of an annotation member to the value of another annotation member. To do this you can use the annotation to alias the value of one member to the value of another.

    A common use case is for example when an annotation defines the value() member, but also supports other members. For example the @Client annotation:

    The @Client Annotation

    If you do not have control over the annotation then another approach is to use an . To create an AnnotationMapper you must perform the following steps:

    The following is an example the AnnotationMapper that improves the introspection capabilities of JPA entities

    EntityIntrospectedAnnotationMapper Mapper Example