Spring Contract StubRunner 2.0.1. Выпуск Заглушки не найдены в classpath - PullRequest
0 голосов
/ 10 апреля 2019

Я пытался использовать приведенную ниже зависимость контракта для тестов на стороне клиента:

    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-contract-stub-runner</artifactId>
      <version>2.0.1.RELEASE</version>
      <scope>test</scope>
    </dependency>

В файле pom.xml я включил ниже зависимость, и зависимость доступна в .m2 / repository:

<dependency>
      <groupId>resmed</groupId>
      <artifactId>pds-service</artifactId>
      <version>0.0.1-SNAPSHOT-1</version>
      <classifier>stubs</classifier>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

Вот конфигурация теста весеннего контракта:

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringBootApplication.class)
@AutoConfigureJsonTesters
@AutoConfigureStubRunner(ids = "mycompany:pds-service:+:stubs:8360")
@DirtiesContext

Но я получил следующее исключение:

Caused by: java.lang.IllegalStateException: No stubs were found on classpath for [mycompany:pds-service]
 at org.springframework.cloud.contract.stubrunner.ClasspathStubProvider$1.downloadAndUnpackStubJar(ClasspathStubProvider.java:99)
              at org.springframework.cloud.contract.stubrunner.CompositeStubDownloader.downloadAndUnpackStubJar(CompositeStubDownloaderBuilder.java:80)
              at org.springframework.cloud.contract.stubrunner.StubRunnerFactory.createStubsFromServiceConfiguration(StubRunnerFactory.java:66)
              at org.springframework.cloud.contract.stubrunner.BatchStubRunnerFactory.buildBatchStubRunner(BatchStubRunnerFactory.java:69)
              at org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration.batchStubRunner(StubRunnerConfiguration.java:84)
              at org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration$$EnhancerBySpringCGLIB$$113b6f08.CGLIB$batchStubRunner$0(<generated>)
              at org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration$$EnhancerBySpringCGLIB$$113b6f08$$FastClassBySpringCGLIB$$123beb15.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
              at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
              at org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration$$EnhancerBySpringCGLIB$$113b6f08.batchStubRunner(<generated>)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
              ... 74 more

Если я использую stubsMode = StubRunnerProperties.StubsMode.LOCAL, все работает хорошо(с производителем местной сборки).Но я должен использовать версию из nexus, поэтому локальный режим не помогает.

Проблема, похоже, в том, что заглушка-заглушка не получает файл заглушки из хранилища .m2 / repository, который maven скачал с nexus во время сборки.

Может ли кто-нибудь помочь, основываясь на вышеуказанной информации?Этот похожий код работает с 1.2.1.И я проверил ссылку ниже, но не помогло.

https://github.com/spring-cloud/spring-cloud-contract/wiki/Spring-Cloud-Contract-2.0-Migration-Guide
...