Search code examples
spring-bootspring-boot-testspring-cloud-contract

Handle cyclic dependency on Spring Cloud Contract


I'm having some doubt regarding Spring Cloud Contract in case of cyclic dependency between two modules. If the module A is a producer for the module B, I build A before B in order to get the stub for B. How about the consumer side for A? It will never get the stub from B.

How is it possible to handle this configuration? Is there any guideline or example project?

Thanks


Solution

  • In this case you should use the generateStubsAtRuntime feature (https://docs.spring.io/spring-cloud-contract/docs/current/reference/html/project-features.html#features-stub-runner-generate-stubs-at-runtime). If the contracts are available you can generate stubs on the consumer side at runtime, until the producer side generates the stubs on their side.