我是 spring-cloud-contract 的新手。只是试图配置我的构建,我得到了错误。
这是我的项目结构
项目
| ==> 模块
我的项目 build.gradle 中有以下类路径依赖项
项目构建文件
buildscript {
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2.1"
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.4.RELEASE")
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:1.1.3.RELEASE"
}
apply from: "$projectDir/gradle/app/springcloud.gradle" //Gradle build file in module
}
模块构建文件
apply plugin: 'groovy'
apply plugin: 'spring-cloud-contract'
apply plugin: 'org.springframework.boot'
dependencies {
//Spring cloud contract dependencies
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.cloud:spring-cloud-starter-contract-verifier')
testCompile "org.springframework.cloud:spring-cloud-starter-contract-stub-runner"
testCompile "com.jayway.restassured:rest-assured:2.5.0"
testCompile "com.jayway.restassured:spring-mock-mvc:2.5.0"
}
//Spring cloud contract dependency management
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Dalston.RELEASE"
}
}
我有一个 groovy 文件,其中包含一个发布请求和一个响应。当我这样做gradle build
时,测试是自动生成的,但我的构建是感觉的。
C:\Users\user\Projects\myProject\module\build\generated-test-sources\contracts\org\springframework\cloud\contract\verifier\tests\ContractVerifierTest.java:3: error: cannot find symbol
import com.jayway.jsonpath.DocumentContext;
^
symbol: class DocumentContext
location: package com.jayway.jsonpath
C:\Users\user\Projects\myProject\module\build\generated-test-sources\contracts\org\springframework\cloud\contract\verifier\tests\ContractVerifierTest.java:28: error: cannot find symbol
DocumentContext parsedJson =
JsonPath.parse(response.getBody().asString());
^
难道我做错了什么?我使用的版本是否有任何不匹配?