Skip to content

Spring Boot Test Jars + Spring Cloud Config #83

@rwinch

Description

@rwinch

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions