Overview

Affects: 6.2

Following up on this comment, we have prototyped a change to Spring Boot that is a step towards replacing its support for injecting a DynamicPropertyRegistry with support for DynamicPropertyRegistrar beans instead.

As explained in the comment in #33501, additional support for DynamicPropertyRegistrar is needed for dynamic property registration when using Testcontainers at development time. In tests, it isn't needed as the test context framework already enables the support through its context customizer.

The prototype of the changes to Boot currently uses reflection when defining a DynamicPropertyRegistrarBeanInitializer bean as the initializer is package-private. This has helped to verify the approach but isn't something that we'd want to ship.

Can Framework 6.2 please provide an SPI for enabling DynamicPropertyRegistrar support outside of the test context framework, or perhaps just make DynamicPropertyRegistrarBeanInitializer public so that we don't need to use reflection?

Related Issues

  • 33501

Comment From: sbrannen

Thanks for raising the issue, @wilkinsona.

Following up on this comment,

I apologize: I somehow missed that comment.

we have prototyped a change to Spring Boot that is a step towards replacing its support for injecting a DynamicPropertyRegistry with support for DynamicPropertyRegistrar beans instead.

That would of course be great if Spring Boot can benefit from the new DynamicPropertyRegistrar support.

Can Framework 6.2 please provide an SPI for enabling DynamicPropertyRegistrar support outside of the test context framework, or perhaps just make DynamicPropertyRegistrarBeanInitializer public so that we don't need to use reflection?

In Spring Framework, we don't have any support for "dynamic properties" other than in the spring-test module. In other words, dynamic properties are very test-centric from a Framework perspective. In light of that, we don't have any plans to enable DynamicPropertyRegistrar support outside of the test context framework.

However, I think it should be fine to make DynamicPropertyRegistrarBeanInitializer public.

Shall I go ahead and make that change this week so that you can try it out with 6.2 snapshots?

Comment From: wilkinsona

Yes please, Sam. Support that's only available in spring-test would work well for us as folks using Testcontainers at development time will already have a dependency on spring-test.

Comment From: sbrannen

DynamicPropertyRegistrarBeanInitializer is now public on main.

Feel free to try it out in upcoming 6.2 snapshots.

Comment From: wilkinsona

I've updated the prototype and it looks good to me. Thanks!

Comment From: sbrannen

Great! Glad to hear that.