spring-boot-starter-test从 2.0.6 开始使用会引入 JUnit 4 依赖项。我如何使用spring-boot-starter-test(通过 Gradle),但使用 JUnit 5,而不引入 JUnit 4 依赖项?
如果有帮助,这是 Gradle 依赖项输出的一部分:
+--- org.springframework.boot:spring-boot-starter-test -> 2.0.5.RELEASE
| +--- org.springframework.boot:spring-boot-starter:2.0.5.RELEASE (*)
| +--- org.springframework.boot:spring-boot-test:2.0.5.RELEASE
| | \--- org.springframework.boot:spring-boot:2.0.5.RELEASE (*)
| +--- org.springframework.boot:spring-boot-test-autoconfigure:2.0.5.RELEASE
| | +--- org.springframework.boot:spring-boot-test:2.0.5.RELEASE (*)
| | \--- org.springframework.boot:spring-boot-autoconfigure:2.0.5.RELEASE (*)
| +--- com.jayway.jsonpath:json-path:2.4.0
| | +--- net.minidev:json-smart:2.3
| | | \--- net.minidev:accessors-smart:1.2
| | | \--- org.ow2.asm:asm:5.0.4
| | \--- org.slf4j:slf4j-api:1.7.25
| +--- junit:junit:4.12
| | \--- org.hamcrest:hamcrest-core:1.3
这是我的build.gradle文件:
buildscript {
ext {
springBootVersion = '2.0.6.RELEASE'
rootGradleDir = "${rootProject.rootDir}/gradle"
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply from: "${rootGradleDir}/staticCodeAnalysis.gradle"
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
test {
useJUnitPlatform()
}
四季花海
温温酱
蝴蝶刀刀
相关分类