Search code examples
spring-cloud-contract

spring cloud contract POC


I am trying to create an example POC for my team to use Spring cloud contract.

I was able to receive Green-Pass for Producer side but on Consumer side, I keep getting
No stubs or contracts were found for [com.datson:cloudcontract-producer:+:stubs] and the switch to fail on no stubs was set. The contracts are present.

I tried several user-case as described in the offical spring cloud document.

@AutoConfigureStubRunner(ids = "com.datson:cloudcontract-producer:+:8080", stubsMode = StubRunnerProperties.StubsMode.LOCAL)

@AutoConfigureStubRunner(ids = "com.datson:cloudcontract-producer:+:stubs"

https://cloud.spring.io/spring-cloud-contract/reference/html/getting-started.html#getting-started-cdc-consumer-run

here is the consumer code sample: https://github.com/Yayan89/springboot-config-server/tree/master/cloudcontract-consumer
here is the producer code sample: https://github.com/Yayan89/springboot-config-server/tree/master/cloudcontract-producer

Might be something silly that I missed out.


Solution

  • In the presented samples you need to install a jar in your local m2 to fetch it from the consumer side (please read the documentation on how to fetch the contracts directly from the drive). If you check this sample and the gradle build https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/scripts/runGradleBuilds.sh#L37 you will see that you should run sth like this

    ./gradlew build publishToMavenLocal
    

    assuming that you have maven-publish plugin or

    ./gradlew build install
    

    assuming that you have a maven plugin