I have an issue with building spring-cloud-contract-verifier
with below pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<docker-maven-plugin.version>1.2.0</docker-maven-plugin.version>
<spring-cloud.version>1.3.2.RELEASE</spring-cloud.version>
<geometry.version>2.11</geometry.version>
<mockito.version>1.9.5</mockito.version>
</properties>
<dependencies>
<!--############################################# SPRING ####################################################-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>5.0.12.Final</version>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
</dependency>
<!--######################################### SPRING-CLOUD ##################################################-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-verifier</artifactId>
<version>2.1.1.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<version>1.3.3.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>spring-mock-mvc</artifactId>
<version>2.2.0</version>
<scope>test</scope>
</dependency>
<!--############################################## MYSQL ####################################################-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--############################################### GEO #####################################################-->
<dependency>
<groupId>com.jillesvangurp</groupId>
<artifactId>geogeometry</artifactId>
<version>${geometry.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--############################################ MOCKITO ####################################################-->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<!--##################################### END-OF-DEPENDENCIES ###############################################-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>1.2.2.RELEASE</version>
<extensions>true</extensions>
<configuration>
<baseClassForTests>
com.foo.pricing.contract.BaseClass
</baseClassForTests>
</configuration>
</plugin>
</plugins>
</build>
I attempt to clean install
the project in order to have my test classes be generated by spring-cloud-contract
.
BaseClass
is as below:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = PricingServiceApplication.class)
@DirtiesContext
public class BaseClass {
@Autowired
private RateChartController rateChartController;
@Before
public void setup() {
StandaloneMockMvcBuilder standaloneMockMvcBuilder = MockMvcBuilders
.standaloneSetup(rateChartController);
RestAssuredMockMvc.standaloneSetup(standaloneMockMvcBuilder);
}
}
The exception I stumble upon comes as follow:
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ PricingService ---
[INFO]
[INFO] --- spring-cloud-contract-maven-plugin:1.2.2.RELEASE:generateStubs (default-generateStubs) @ PricingService ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.079 s
[INFO] Finished at: 2019-03-13T16:09:17+03:30
[INFO] Final Memory: 62M/483M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.cloud:spring-cloud-contract-maven-plugin:1.2.2.RELEASE:generateStubs (default-generateStubs) on project PricingService: Stubs could not be found: [/home/akarimin/project/foo/pricing-service/pricing/target/stubs] .
[ERROR] Please make sure that spring-cloud-contract:convert was invoked
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
I appreciate if you could help me to resolve this issue.
After a few days struggling to find the solution, I came to the conclusion that my Spring Boot version (1.5.10) is not compatible with Spring Cloud Contract Verifier (2.1.1), although I have not found any compatibility matrix on the web and it is just based on my experiment in this case. By migrating to Spring Boot 2.1.x the issue was resolved and it is working like a charm. Many thanks to Josh Long & Marcin Grzejszczak for the presentation in conference about Spring Contract.