Annotation Interface RegisterReflectionForBinding


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented @RegisterReflection @Reflective(org.springframework.aot.hint.annotation.RegisterReflectionForBindingProcessor.class) public @interface RegisterReflectionForBinding
Register reflection hints for data binding or reflection-based serialization against an arbitrary number of target classes.

For each class hints are registered for constructors, fields, properties, and record components. Hints are also registered for types transitively used on properties and record components.

You can use this annotation on any bean that is contributed to the context:


 @Configuration
 @RegisterReflectionForBinding({Foo.class, Bar.class})
 class MyConfig {
     // ...
 }

If scanning of Reflective is enabled, any type in the configured packages can use this annotation as well.

When the annotated element is a type, the type itself is registered if no candidates are provided:


 @Component
 @RegisterReflectionForBinding
 class MyBean {
     // ...
 }
The annotation can also be specified on a method. In that case, at least one target class must be specified:

 @Component
 class MyService {

     @RegisterReflectionForBinding(Baz.class)
     public Baz process() {
         // ...
     }

 }

The annotated element can also be any test class that uses the Spring TestContext Framework to load an ApplicationContext.

Since:
6.0
Author:
Sebastien Deleuze, Stephane Nicoll
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
    Classes for which reflection hints should be registered.
    Alternative to classes() to specify the classes as class names.
    Class<?>[]
    Alias for classes().