最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Gradle build is failing [Spring Cloud Contract Verifier Plugin exception: Process 'java17.exe' finished with non

programmeradmin1浏览0评论

I'm trying to create a new consumer application using Gradle and spring contract stub runner. I'm stuck on the error **Execution failed for task ':generateClientStubs'.

Spring Cloud Contract Verifier Plugin exception: Process 'command 'C:\Program Files\Amazon Corretto\jdk17.0.13_11\bin\java.exe'' finished with non-zero exit value 1**

gradle.build

buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
        maven { url "; }
        maven { url "; }
        maven { url "; }
    }
    dependencies {
        classpath ".springframework.boot:spring-boot-gradle-plugin:2.5.4"
        classpath ".springframework.cloud:spring-cloud-contract-gradle-plugin:3.1.4"
    }
}

plugins {
    id 'java'
    id '.springframework.boot' version '2.5.4'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id '.springframework.cloud.contract' version '3.1.4'  // Spring Cloud Contract plugin version
}

ext {
    springboot_version = '2.5.4'
    verifier_version = '3.1.4'
    cloud_version = '2020.0.4'
    springCloudVersion = "2020.0.6" // Adjust based on Spring Cloud version compatibility
}

repositories {
    mavenCentral()
    mavenLocal()
    maven { url "; }
    maven { url "; }
    maven { url "; }
}

dependencyManagement {
    imports {
        mavenBom ".springframework.cloud:spring-cloud-contract-dependencies:3.1.4"
        mavenBom ".springframework.cloud:spring-cloud-dependencies:$springCloudVersion"
    }
}

dependencies {
    implementation '.springframework.boot:spring-boot-starter-web'
    implementation '.springframework.boot:spring-boot-starter-webflux'
    implementation '.projectlombok:lombok'
    testImplementation '.spockframework:spock-core:1.0-groovy-2.4'
    testImplementation '.springframework.cloud:spring-cloud-starter-contract-stub-runner'
    testImplementation group: 'io.rest-assured', name: 'spring-mock-mvc', version: '3.0.0'

}

bootJar {
    archiveFileName = 'stubbing-ms'
    version = '0.0.1-SNAPSHOT'
}

contracts {
    // To have the same contract folder as Maven. In Gradle would default to
    // src/contractTest/resources/contracts
    baseClassMappings {
        baseClassMapping(".*example.*", "com.example.BaseClass")
    }
}

Contract

package contracts

import .springframework.cloud.contract.spec.Contract

Contract.make {
    description "should return a patient detail"
    request {
        method GET()
        url("/patient/123")
    }
    response {
        status 200
        body(
                id: 123,
                name: "John Doe",
                email: "[email protected]"
        )
        headers {
            contentType(applicationJson())
        }
    }
}

BaseClass

@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = StubRunnerApplication.class)
public class BaseClass {

    @Autowired
    PatientController patientController;

    @BeforeEach
    public void setUp() {
        RestAssuredMockMvc.standaloneSetup(patientController);
    }
}

No other test class, Code have a controller which calls service and return the ResponseEntity.

I have tried and other guides, But unable to find the solution. I'm very much new to gradle. So its hard for me to understand the errors and debug them. Anyone faced same issue or have good experties please help me in resolving the issue

发布评论

评论列表(0)

  1. 暂无评论