首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复执行任务失败的‘:编译测试task’?

如何修复执行任务失败的‘:编译测试task’?
EN

Stack Overflow用户
提问于 2020-09-29 03:03:12
回答 1查看 714关注 0票数 0

我已经使用Gradle启动了一个Java,在那里我将必要的Spring Boot库导入到build.gradle中。在我构建该项目时,它给了我以下错误:

误差

代码语言:javascript
复制
Execution failed for task ':compileTestJava'.
> Could not resolve all files for configuration ':testCompileClasspath'.
   > Could not find org.apache.httpcomponents:httpclient:1.2.5.
     Required by:
         project :
   > Could not find org.apache.httpcomponents:httpclient:1.2.5.
     Required by:
         project : > io.rest-assured:rest-assured:4.1.2
   > Could not find org.apache.httpcomponents:httpclient:1.2.5.
     Required by:
         project : > com.microsoft.sqlserver:mssql-jdbc:6.1.0.jre8 > com.microsoft.azure:azure-keyvault:0.9.3
         project : > com.microsoft.sqlserver:mssql-jdbc:6.1.0.jre8 > com.microsoft.azure:azure-keyvault:0.9.3 > com.microsoft.azure:azure-core:0.9.3
   > Could not find org.apache.httpcomponents:httpclient:1.2.5.
     Required by:
         project : > io.rest-assured:rest-assured:4.1.2 > org.apache.httpcomponents:httpmime:4.5.12
Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

Build.Gradle

代码语言:javascript
复制
apply plugin: 'java'


sourceCompatibility = 1.8
targetCompatibility = 1.8


group 'AbtMainTestControl'
version '1.0-SNAPSHOT'

// Versioning of dependencies
wrapper.gradleVersion = '5.5.1'
def cucumberVersion = '4.7.1'
def junitVersion = '5.5.0'
def restVersion = '4.1.2'
def apacheDrillVersion = '1.17.0'



repositories {
    jcenter()
    mavenCentral()
}



dependencies {
    compile group: 'org.codehaus.jackson', name: 'jackson-core-asl', version: '1.9.13'
    compile group: 'com.opencsv', name: 'opencsv', version: '4.0'

    compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '1.2.5'

    // https://mvnrepository.com/artifact/org.apache.drill.tools/tools-parent
    compile group: 'org.apache.drill.tools', name: 'tools-parent', version: "${apacheDrillVersion}", ext: 'pom'

    // Cucumber Pretty Report Plugin
    compile group: 'de.monochromata.cucumber', name: 'reporting-plugin', version: '3.0.9'
    
    testCompile group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '6.1.0.jre8'

    compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.7.0'

    
    testImplementation "io.cucumber:cucumber-java:${cucumberVersion}"
    testImplementation "io.cucumber:cucumber-junit:${cucumberVersion}"
    testImplementation "io.rest-assured:rest-assured:${restVersion}"
    testImplementation "io.rest-assured:json-path:${restVersion}"
    testImplementation "io.rest-assured:json-schema-validator:${restVersion}"

    testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
    testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junitVersion}"
    implementation 'junit:junit:4.12'
}


configurations {
    cucumberRuntime {
        extendsFrom testImplementation
    }
}

task cucumber() {
    dependsOn assemble, compileTestJava
    doLast {
        javaexec {
            main = "io.cucumber.core.cli.Main"
            classpath =  configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
            args = ['--plugin',
                    'pretty',
                    '--glue',
                    'gradle.cucumber',
                    'src/test/resources/features',

            ]
        }
    }
}


test {
    //useJUnitPlatform()
    systemProperty "cucumber.options", System.properties.getProperty("cucumber.options")
}

在本例中,我提取了Spring,以便查看Build.Gradle文件中的问题所在

有人能推荐解决办法/帮助我解决这个问题吗?你的建议将不胜感激:)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-29 03:34:48

httpclient的版本-- 1.2.5 --看起来有点差;最新版本是4.5.12。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64112256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档