-
Notifications
You must be signed in to change notification settings - Fork 10
Description
I've put together a minimal sample of Spring Boot testjars and Spring Cloud Config working together. I'd like to discuss some of the challenges that I faced and see how things might change.
Both Testjars and Spring Boot use Spring Framework's DynamicPropertyRegistry. However, Spring Cloud currently updates the Environment by implementing Spring Boot's ConfigDataLoader.
As it stands, Spring Boot Testjars will not work with Spring Cloud Config because ConfigDataLoader runs before any DynamicPropertyRegistry and Testjars needs to startup a config server and resolve its port to provide the config server url to Spring Cloud before spring cloud config client can add the entries to the Environment.
One way to resolve this would be for Spring Cloud Config Client to use DynamicPropertyRegistry instead of ConfigDataLoader. The sample that I linked to above uses this approach, but there are some problems:
- DynamicPropertyRegistry needs to be in main for Spring Cloud Config Client to be able to replace the ConfigDataLoader with the DynamicPropertyRegistry approach
- The invocations of DynamicPropertyRegistry.accept needs to be ordered so that I can ensure that Testjars is loaded first.