My Use case is,

organisation wide all our microservies are using YAML, so we cannot move from YAMLto .properties. In one of my recent app, I am using testcontainers for Unit tests, where testcontainers randomly selects any available port to start the container. So before running the tests I have to dynamically change the PORT property which is defined in the YAML file. For .properties file, it was straightforward with ApplicationContextInitializer& TestPropertyValues- like TestPropertyValues.of("spring.rabbitmq.port" + container.getMappedPort(5672)).applyTo(applicationContext);

Not able to achieve this, being the port property is defined in the YAML file.

Any workaround / suggestions ?

Comment From: quaff

Please refer to https://github.com/spring-projects/spring-framework/issues/24540

Comment From: bsideup

Also see https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-testcontainers

Comment From: sbrannen

Closing this issue as a duplicate of #24540.

If you find that @DynamicPropertySource does not meet your needs, feel free to post back here.

Comment From: raahool

Which version of Spring has this annotation. Currently our enterprise is on SpringBoot 2.2.4.RELEASE version.