Interface DynamicPropertyRegistry


public interface DynamicPropertyRegistry
Registry that is used to add properties with dynamically resolved values to the 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 supplied to DynamicPropertyRegistrar beans in the test's ApplicationContext, making it possible to register dynamic properties based on beans in the context. For example, a @Bean method can return a DynamicPropertyRegistrar that registers a property whose value is dynamically sourced from another bean in the context. See the documentation for DynamicPropertyRegistrar for an example.

Since:
5.2.5
Author:
Phillip Webb, Sam Brannen
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String name, Supplier<Object> valueSupplier)
    Add a Supplier for the given property name to this registry.
  • Method Details

    • add

      void add(String name, Supplier<Object> valueSupplier)
      Add a Supplier for the given property name to this registry.
      Parameters:
      name - the name of the property for which the supplier should be added
      valueSupplier - a supplier that will provide the property value on demand