Spring boot 未解析引用:SpringExtension使用@ExtendWith注释

Spring boot 未解析引用:SpringExtension使用@ExtendWith注释,spring-boot,gradle,junit,kotlin,junit5,Spring Boot,Gradle,Junit,Kotlin,Junit5,我正在尝试在SpringBoot中使用JUnit5,以利用它提供的许多新特性。基本的设置是有效的,我可以使用新的注释,例如@before和@AfterAll,但是,我相信,因为我无法用(SpringExtension::class)解析@extendedwith,所以我无法初始化我的测试类以利用注入的资源。我已尝试将所需的依赖项添加到我的build.gradle文件中,但我认为我缺少一个关键依赖项: buildscript { ext.dokka_version = '0.9.15' ext.

我正在尝试在SpringBoot中使用JUnit5,以利用它提供的许多新特性。基本的设置是有效的,我可以使用新的注释,例如
@before
@AfterAll
,但是,我相信,因为我无法用(SpringExtension::class)解析
@extendedwith,所以我无法初始化我的测试类以利用注入的资源。我已尝试将所需的依赖项添加到我的
build.gradle
文件中,但我认为我缺少一个关键依赖项:

buildscript {

ext.dokka_version = '0.9.15'
ext.dockerVersion = '1.2'
ext.junit4Version = '4.12'
ext.junitVintageVersion = '4.12.2'
ext.junitPlatformVersion = '1.0.2'
ext.junitJupiterVersion = '5.0.2'
ext.kotlin_version = '1.1.60'
ext.log4jVersion = '2.9.0'
ext.springVersion = '1.5.8.RELEASE'

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    // Needed for the 'kotlin' plugin
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}")
    // Needed for the 'org.springframework.boot' plugin
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springVersion}")
    // Needed for the 'kotlin-spring' plugin
    classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}")
    //Needed for 'docker' plugin
    classpath("se.transmode.gradle:gradle-docker:${dockerVersion}")
    //Needed for 'dokka' plugin
    classpath("org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}")
    // Needed for Junit 5
    classpath("org.junit.platform:junit-platform-gradle-plugin:${junitPlatformVersion}")
}

}

// Allows us to compile Kotlin files
apply plugin: 'kotlin'
// Does some extra work to set up Spring Boot.
// Specifically this gives us the "bootRun" task we will be using
apply plugin: 'org.springframework.boot'
// Allows for improved interoperability between Kotlin and Spring
apply plugin: 'kotlin-spring'
// Allows us to create docker image
apply plugin: 'docker'
//Allows us to create API documentation
apply plugin: 'org.jetbrains.dokka'

apply plugin: 'idea'

apply plugin: 'java'

apply plugin: 'org.junit.platform.gradle.plugin'


junitPlatform {
    // platformVersion '1.0.2'
    filters {
        engines {
            // include 'junit-jupiter', 'junit-vintage'
            // exclude 'custom-engine'
        }
        tags {
            // include 'fast'
            exclude 'slow'
        }
        // includeClassNamePattern '.*Test'
    }
    // enableStandardTestTask true
    // reportsDir file('build/test-results/junit-platform') // this is the default
    //logManager 'org.apache.logging.log4j.jul.LogManager'
}

task buildDocker(type: Docker, dependsOn: [build, dokka]) {
    applicationName = jar.baseName
    dockerfile = file('Dockerfile')
    doFirst {
        copy {
            from jar
            into stageDir
        }
    }
}

dokka {
    outputFormat = 'html'
    outputDirectory = $buildDir / doc
}

repositories {
    mavenCentral()
}

compileJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}

compileTestJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
    options.compilerArgs += '-parameters'
}

dependencies {
// JPA and H2
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("com.h2database:h2")

compile "org.hibernate:hibernate-entitymanager:5.2.10.Final"
compile "org.hibernate:hibernate-core:5.2.10.Final"

compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

compile "org.slf4j:slf4j-api:1.7.25"

// Kotlin Dependencies
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

testCompile "org.springframework.boot:spring-boot-starter-test"
//testCompile "org.springframework.boot:spring-boot-starter-test" {
//    exclude(module = "junit")
//}
// Mockito
//testCompile "org.mockito:mockito-core:2.11.0"
//testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0"

//AssertJ
testCompile 'org.assertj:assertj-core:3.8.0'

// JUnit Jupiter API and TestEngine implementation
testCompile("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}")
testCompile("org.junit.platform:juint-platform-runner:${junitPlatformVersion}")
testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}")

// Only needed to run tests in an (IntelliJ) IDE(A) that bundles an older version
testRuntime("org.junit.platform:junit-platform-launcher:${junitPlatformVersion}")

// If you also want to support JUnit 3 and JUnit 4 tests
//testCompile ("junit:junit:${junit4Version}")
//testRuntime ("org.junit.vintage:junit-vintage-engine:${junitVintageVersion}")

// To avoid compiler warnings about @API annotations in JUnit code
testCompileOnly("org.apiguardian:apiguardian-api:1.0.0")

// Spring Dependencies
compile("org.springframework.boot:spring-boot-starter-web") {
    exclude module: "spring-boot-starter-tomcat"
}
compile "org.springframework.boot:spring-boot-starter-jetty"
compile "org.springframework.boot:spring-boot-starter-actuator"

// Jackson Dependencies
compile "com.fasterxml.jackson.core:jackson-annotations"
compile "com.fasterxml.jackson.core:jackson-core"
compile "com.fasterxml.jackson.core:jackson-databind"
runtime "com.fasterxml.jackson.datatype:jackson-datatype-jdk8"
runtime "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
runtime "com.fasterxml.jackson.module:jackson-module-kotlin"
}

configurations.all {
    exclude group: "org.slf4j", module: "slf4j-log4j12"
    exclude group: "log4j", module: "log4j"
}

task wrapper(type: Wrapper) {
    gradleVersion = "4.3"
}
dependencies {
    compile 'org.springframework:spring-context:5.0.1.RELEASE'
}

我看不到
build.gradle
中声明的
spring-test-junit5
依赖项。根据报告:

如果您想根据spring-test-junit5的发布标签进行构建,您可能会对使用JitPack感兴趣。例如,要根据1.0.2标记构建,以下Maven坐标将起作用

带渐变的JitPack

更新:

摘自以下评论(由JUnit5 Spring扩展的作者提供):

如果您使用的是SpringFramework 5.x中的SpringTest,则不需要spring-test-junit5工件(它仅适用于SpringFramework 4.3.x)


我看不到
build.gradle
中声明的
spring-test-junit5
依赖项。根据报告:

如果您想根据spring-test-junit5的发布标签进行构建,您可能会对使用JitPack感兴趣。例如,要根据1.0.2标记构建,以下Maven坐标将起作用

带渐变的JitPack

更新:

摘自以下评论(由JUnit5 Spring扩展的作者提供):

如果您使用的是SpringFramework 5.x中的SpringTest,则不需要spring-test-junit5工件(它仅适用于SpringFramework 4.3.x)


我缺少以下依赖项:

buildscript {

ext.dokka_version = '0.9.15'
ext.dockerVersion = '1.2'
ext.junit4Version = '4.12'
ext.junitVintageVersion = '4.12.2'
ext.junitPlatformVersion = '1.0.2'
ext.junitJupiterVersion = '5.0.2'
ext.kotlin_version = '1.1.60'
ext.log4jVersion = '2.9.0'
ext.springVersion = '1.5.8.RELEASE'

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    // Needed for the 'kotlin' plugin
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}")
    // Needed for the 'org.springframework.boot' plugin
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springVersion}")
    // Needed for the 'kotlin-spring' plugin
    classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}")
    //Needed for 'docker' plugin
    classpath("se.transmode.gradle:gradle-docker:${dockerVersion}")
    //Needed for 'dokka' plugin
    classpath("org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}")
    // Needed for Junit 5
    classpath("org.junit.platform:junit-platform-gradle-plugin:${junitPlatformVersion}")
}

}

// Allows us to compile Kotlin files
apply plugin: 'kotlin'
// Does some extra work to set up Spring Boot.
// Specifically this gives us the "bootRun" task we will be using
apply plugin: 'org.springframework.boot'
// Allows for improved interoperability between Kotlin and Spring
apply plugin: 'kotlin-spring'
// Allows us to create docker image
apply plugin: 'docker'
//Allows us to create API documentation
apply plugin: 'org.jetbrains.dokka'

apply plugin: 'idea'

apply plugin: 'java'

apply plugin: 'org.junit.platform.gradle.plugin'


junitPlatform {
    // platformVersion '1.0.2'
    filters {
        engines {
            // include 'junit-jupiter', 'junit-vintage'
            // exclude 'custom-engine'
        }
        tags {
            // include 'fast'
            exclude 'slow'
        }
        // includeClassNamePattern '.*Test'
    }
    // enableStandardTestTask true
    // reportsDir file('build/test-results/junit-platform') // this is the default
    //logManager 'org.apache.logging.log4j.jul.LogManager'
}

task buildDocker(type: Docker, dependsOn: [build, dokka]) {
    applicationName = jar.baseName
    dockerfile = file('Dockerfile')
    doFirst {
        copy {
            from jar
            into stageDir
        }
    }
}

dokka {
    outputFormat = 'html'
    outputDirectory = $buildDir / doc
}

repositories {
    mavenCentral()
}

compileJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}

compileTestJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
    options.compilerArgs += '-parameters'
}

dependencies {
// JPA and H2
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("com.h2database:h2")

compile "org.hibernate:hibernate-entitymanager:5.2.10.Final"
compile "org.hibernate:hibernate-core:5.2.10.Final"

compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

compile "org.slf4j:slf4j-api:1.7.25"

// Kotlin Dependencies
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

testCompile "org.springframework.boot:spring-boot-starter-test"
//testCompile "org.springframework.boot:spring-boot-starter-test" {
//    exclude(module = "junit")
//}
// Mockito
//testCompile "org.mockito:mockito-core:2.11.0"
//testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0"

//AssertJ
testCompile 'org.assertj:assertj-core:3.8.0'

// JUnit Jupiter API and TestEngine implementation
testCompile("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}")
testCompile("org.junit.platform:juint-platform-runner:${junitPlatformVersion}")
testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}")

// Only needed to run tests in an (IntelliJ) IDE(A) that bundles an older version
testRuntime("org.junit.platform:junit-platform-launcher:${junitPlatformVersion}")

// If you also want to support JUnit 3 and JUnit 4 tests
//testCompile ("junit:junit:${junit4Version}")
//testRuntime ("org.junit.vintage:junit-vintage-engine:${junitVintageVersion}")

// To avoid compiler warnings about @API annotations in JUnit code
testCompileOnly("org.apiguardian:apiguardian-api:1.0.0")

// Spring Dependencies
compile("org.springframework.boot:spring-boot-starter-web") {
    exclude module: "spring-boot-starter-tomcat"
}
compile "org.springframework.boot:spring-boot-starter-jetty"
compile "org.springframework.boot:spring-boot-starter-actuator"

// Jackson Dependencies
compile "com.fasterxml.jackson.core:jackson-annotations"
compile "com.fasterxml.jackson.core:jackson-core"
compile "com.fasterxml.jackson.core:jackson-databind"
runtime "com.fasterxml.jackson.datatype:jackson-datatype-jdk8"
runtime "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
runtime "com.fasterxml.jackson.module:jackson-module-kotlin"
}

configurations.all {
    exclude group: "org.slf4j", module: "slf4j-log4j12"
    exclude group: "log4j", module: "log4j"
}

task wrapper(type: Wrapper) {
    gradleVersion = "4.3"
}
dependencies {
    compile 'org.springframework:spring-context:5.0.1.RELEASE'
}
最终,由于我的build.gradle,存在很多依赖项不匹配。确保所有的spring模块都是从5.0.1.RELEASE中派生出来的。我从以前的版本中发现了一些导致不同错误的模块。我最终定义了我的版本:

    ext {
    antJunitVersion = '1.9.7'
    assertjcoreVersion = '3.8.0'
    apiguardianVersion = '1.0.0'
    dokkaVersion = '0.9.15'
    dockerVersion = '1.2'
    h2Version = '1.4.196'
    hibernateVersion = '5.2.12.Final'
    jacksonVersion = '2.9.1'
    junit4Version = '4.12'
    junitVintageVersion = '4.12.2'
    junitPlatformVersion = '1.0.2'
    junitJupiterVersion = '5.0.2'
    kotlinVersion = '1.1.60'
    log4jVersion = '2.9.1'
    springVersion = '5.0.1.RELEASE'
    springBootVersion = '1.5.8.RELEASE'
    slf4jVersion = '1.7.25'
}
然后将它们声明为显式依赖项

// Spring Dependencies
compile("org.springframework:spring-webmvc:${springVersion}")
compile("org.springframework:spring-web:${springVersion}")
compile("org.springframework:spring-aspects:${springVersion}")
compile("org.springframework:spring-aop:${springVersion}")
compile("org.springframework:spring-orm:${springVersion}")
compile("org.springframework:spring-jdbc:${springVersion}")
compile("org.springframework:spring-tx:${springVersion}")
compile("org.springframework:spring-beans:${springVersion}")
compile("org.springframework:spring-expression:${springVersion}")
compile("org.springframework:spring-core:${springVersion}")
compile("org.springframework:spring-context:${springVersion}")
compile("org.springframework:spring-test:${springVersion}")
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}") {
    exclude module: "spring-boot-starter-tomcat"
}
compile "org.springframework.boot:spring-boot-starter-jetty:${springBootVersion}"
compile "org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}"

我缺少以下依赖项:

buildscript {

ext.dokka_version = '0.9.15'
ext.dockerVersion = '1.2'
ext.junit4Version = '4.12'
ext.junitVintageVersion = '4.12.2'
ext.junitPlatformVersion = '1.0.2'
ext.junitJupiterVersion = '5.0.2'
ext.kotlin_version = '1.1.60'
ext.log4jVersion = '2.9.0'
ext.springVersion = '1.5.8.RELEASE'

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    // Needed for the 'kotlin' plugin
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}")
    // Needed for the 'org.springframework.boot' plugin
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springVersion}")
    // Needed for the 'kotlin-spring' plugin
    classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}")
    //Needed for 'docker' plugin
    classpath("se.transmode.gradle:gradle-docker:${dockerVersion}")
    //Needed for 'dokka' plugin
    classpath("org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}")
    // Needed for Junit 5
    classpath("org.junit.platform:junit-platform-gradle-plugin:${junitPlatformVersion}")
}

}

// Allows us to compile Kotlin files
apply plugin: 'kotlin'
// Does some extra work to set up Spring Boot.
// Specifically this gives us the "bootRun" task we will be using
apply plugin: 'org.springframework.boot'
// Allows for improved interoperability between Kotlin and Spring
apply plugin: 'kotlin-spring'
// Allows us to create docker image
apply plugin: 'docker'
//Allows us to create API documentation
apply plugin: 'org.jetbrains.dokka'

apply plugin: 'idea'

apply plugin: 'java'

apply plugin: 'org.junit.platform.gradle.plugin'


junitPlatform {
    // platformVersion '1.0.2'
    filters {
        engines {
            // include 'junit-jupiter', 'junit-vintage'
            // exclude 'custom-engine'
        }
        tags {
            // include 'fast'
            exclude 'slow'
        }
        // includeClassNamePattern '.*Test'
    }
    // enableStandardTestTask true
    // reportsDir file('build/test-results/junit-platform') // this is the default
    //logManager 'org.apache.logging.log4j.jul.LogManager'
}

task buildDocker(type: Docker, dependsOn: [build, dokka]) {
    applicationName = jar.baseName
    dockerfile = file('Dockerfile')
    doFirst {
        copy {
            from jar
            into stageDir
        }
    }
}

dokka {
    outputFormat = 'html'
    outputDirectory = $buildDir / doc
}

repositories {
    mavenCentral()
}

compileJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}

compileTestJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
    options.compilerArgs += '-parameters'
}

dependencies {
// JPA and H2
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("com.h2database:h2")

compile "org.hibernate:hibernate-entitymanager:5.2.10.Final"
compile "org.hibernate:hibernate-core:5.2.10.Final"

compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

compile "org.slf4j:slf4j-api:1.7.25"

// Kotlin Dependencies
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

testCompile "org.springframework.boot:spring-boot-starter-test"
//testCompile "org.springframework.boot:spring-boot-starter-test" {
//    exclude(module = "junit")
//}
// Mockito
//testCompile "org.mockito:mockito-core:2.11.0"
//testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0"

//AssertJ
testCompile 'org.assertj:assertj-core:3.8.0'

// JUnit Jupiter API and TestEngine implementation
testCompile("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}")
testCompile("org.junit.platform:juint-platform-runner:${junitPlatformVersion}")
testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}")

// Only needed to run tests in an (IntelliJ) IDE(A) that bundles an older version
testRuntime("org.junit.platform:junit-platform-launcher:${junitPlatformVersion}")

// If you also want to support JUnit 3 and JUnit 4 tests
//testCompile ("junit:junit:${junit4Version}")
//testRuntime ("org.junit.vintage:junit-vintage-engine:${junitVintageVersion}")

// To avoid compiler warnings about @API annotations in JUnit code
testCompileOnly("org.apiguardian:apiguardian-api:1.0.0")

// Spring Dependencies
compile("org.springframework.boot:spring-boot-starter-web") {
    exclude module: "spring-boot-starter-tomcat"
}
compile "org.springframework.boot:spring-boot-starter-jetty"
compile "org.springframework.boot:spring-boot-starter-actuator"

// Jackson Dependencies
compile "com.fasterxml.jackson.core:jackson-annotations"
compile "com.fasterxml.jackson.core:jackson-core"
compile "com.fasterxml.jackson.core:jackson-databind"
runtime "com.fasterxml.jackson.datatype:jackson-datatype-jdk8"
runtime "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
runtime "com.fasterxml.jackson.module:jackson-module-kotlin"
}

configurations.all {
    exclude group: "org.slf4j", module: "slf4j-log4j12"
    exclude group: "log4j", module: "log4j"
}

task wrapper(type: Wrapper) {
    gradleVersion = "4.3"
}
dependencies {
    compile 'org.springframework:spring-context:5.0.1.RELEASE'
}
最终,由于我的build.gradle,存在很多依赖项不匹配。确保所有的spring模块都是从5.0.1.RELEASE中派生出来的。我从以前的版本中发现了一些导致不同错误的模块。我最终定义了我的版本:

    ext {
    antJunitVersion = '1.9.7'
    assertjcoreVersion = '3.8.0'
    apiguardianVersion = '1.0.0'
    dokkaVersion = '0.9.15'
    dockerVersion = '1.2'
    h2Version = '1.4.196'
    hibernateVersion = '5.2.12.Final'
    jacksonVersion = '2.9.1'
    junit4Version = '4.12'
    junitVintageVersion = '4.12.2'
    junitPlatformVersion = '1.0.2'
    junitJupiterVersion = '5.0.2'
    kotlinVersion = '1.1.60'
    log4jVersion = '2.9.1'
    springVersion = '5.0.1.RELEASE'
    springBootVersion = '1.5.8.RELEASE'
    slf4jVersion = '1.7.25'
}
然后将它们声明为显式依赖项

// Spring Dependencies
compile("org.springframework:spring-webmvc:${springVersion}")
compile("org.springframework:spring-web:${springVersion}")
compile("org.springframework:spring-aspects:${springVersion}")
compile("org.springframework:spring-aop:${springVersion}")
compile("org.springframework:spring-orm:${springVersion}")
compile("org.springframework:spring-jdbc:${springVersion}")
compile("org.springframework:spring-tx:${springVersion}")
compile("org.springframework:spring-beans:${springVersion}")
compile("org.springframework:spring-expression:${springVersion}")
compile("org.springframework:spring-core:${springVersion}")
compile("org.springframework:spring-context:${springVersion}")
compile("org.springframework:spring-test:${springVersion}")
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}") {
    exclude module: "spring-boot-starter-tomcat"
}
compile "org.springframework.boot:spring-boot-starter-jetty:${springBootVersion}"
compile "org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}"

谢谢,我错过了那些依赖关系。不幸的是,我现在遇到以下错误:失败:生成失败,出现异常。*错误:任务“:spog api:compileTestKotlin”的执行失败。无法解析配置的所有文件:spog api:testCompileClasspath'>找不到com.github.sbrannen:spring-test-junit5:1.0.2。Required by:project:spog不是告诉您仍然缺少spring测试junit依赖项的消息吗?或者至少它在testCompileClasspath上不可用?也许您没有正确地将其添加到build.gradle?作者sbrannen提到他的工作“已经与SPR-13575一起被纳入到springframework5.0中。”因此我认为我不需要对这个原型项目的依赖性。我将查看是否需要SpringFramework5的依赖项。在添加sbrannen和jitpack依赖项之后,我没有看到Gradle发出的任何消息,说它已经下载了这个人工制品。是的,这可以解释错误。如果您使用的是spring Framework 5.x中的
spring-test
,那么您不需要
spring-test-junit5
工件(仅适用于spring Framework 4.3.x)。谢谢,我缺少这些依赖项。不幸的是,我现在遇到以下错误:失败:生成失败,出现异常。*错误:任务“:spog api:compileTestKotlin”的执行失败。无法解析配置的所有文件:spog api:testCompileClasspath'>找不到com.github.sbrannen:spring-test-junit5:1.0.2。Required by:project:spog不是告诉您仍然缺少spring测试junit依赖项的消息吗?或者至少它在testCompileClasspath上不可用?也许您没有正确地将其添加到build.gradle?作者sbrannen提到他的工作“已经与SPR-13575一起被纳入到springframework5.0中。”因此我认为我不需要对这个原型项目的依赖性。我将查看是否需要SpringFramework5的依赖项。在添加sbrannen和jitpack依赖项之后,我没有看到Gradle发出的任何消息,说它已经下载了这个人工制品。是的,这可以解释错误。如果您使用的是SpringFramework 5.x中的
spring-test
,则不需要
spring-test-junit5
工件(仅适用于SpringFramework 4.3.x)。