Annotation Interface ImportRuntimeHints
RuntimeHintsRegistrar
implementations
should be processed.
Unlike declaring RuntimeHintsRegistrar
using
META-INF/spring/aot.factories
, this annotation allows for more flexible
registration where it is only processed if the annotated component or bean
method is actually registered in the bean factory. To illustrate this
behavior, consider the following example:
@Configuration public class MyConfiguration { @Bean @ImportRuntimeHints(MyHints.class) @Conditional(MyCondition.class) public MyService myService() { return new MyService(); } }
If the configuration class above is processed, MyHints
will be
contributed only if MyCondition
matches. If the condition does not
match, MyService
will not be defined as a bean and the hints will
not be processed either.
@ImportRuntimeHints
can also be applied to any test class that uses
the Spring TestContext Framework to load an ApplicationContext
.
If several components or test classes refer to the same RuntimeHintsRegistrar
implementation, the registrar will only be invoked once for the given bean factory
processing or test suite.
- Since:
- 6.0
- Author:
- Brian Clozel, Stephane Nicoll
- See Also:
-
Required Element Summary
Modifier and TypeRequired ElementDescriptionClass<? extends RuntimeHintsRegistrar>[]
RuntimeHintsRegistrar
implementations to process.
-
Element Details
-
value
Class<? extends RuntimeHintsRegistrar>[] valueRuntimeHintsRegistrar
implementations to process.
-