Interface DynamicPropertyRegistry
Environment.
A DynamicPropertyRegistry is supplied as an argument to static
@DynamicPropertySource methods in integration
test classes.
As of Spring Framework 6.2, a DynamicPropertyRegistry is also
registered as a singleton bean in the test's ApplicationContext. This
allows a DynamicPropertyRegistry to be autowired into a
@Configuration class or supplied to a @Bean method as an
argument, making it possible to register a dynamic property from within a test's
ApplicationContext. For example, a @Bean method can register
a property whose value is dynamically sourced from the bean that the method
returns. Note that such a @Bean method can optionally be annotated
with @DynamicPropertySource to enforce eager initialization of the
bean within the context, thereby ensuring that any dynamic properties sourced
from that bean are available to other singleton beans within the context.
See @DynamicPropertySource for an example.
- Since:
- 5.2.5
- Author:
- Phillip Webb, Sam Brannen
- See Also:
-
Method Summary
-
Method Details
-
add
Add aSupplierfor the given property name to this registry.- Parameters:
name- the name of the property for which the supplier should be addedvalueSupplier- a supplier that will provide the property value on demand
-