Ich habe in etwa die folgende Konfiguration:Frühling Boot gradle Plugin Kräfte Mockito Version
test-utils/build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.1.RELEASE'
}
}
apply plugin: 'java'
apply plugin: 'spring-boot'
dependencies {
compile ('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.mockito'
exclude group: 'org.hamcrest'
}
compile 'org.mockito:mockito-core:2.0.41-beta'
compile 'org.assertj:assertj-core:3.3.0'
}
main/build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.1.RELEASE'
}
}
apply plugin: 'java'
apply plugin: 'spring-boot'
dependencies {
testCompile project(':test-utils')
}
Aber aus irgendeinem Grund scheint es, dass die Feder Das Boot-Plugin zwingt die Mockito-Version zurück auf 1.x:
# ./gradlew :main:dependencies --configuration=testCompile
testCompile - Compile classpath for source set 'test'.
+--- project :test-utils
+--- org.springframework.boot:spring-boot-starter-test: -> 1.3.1.RELEASE
| +--- junit:junit:4.12
| +--- org.springframework:spring-core:4.2.4.RELEASE
| \--- org.springframework:spring-test:4.2.4.RELEASE
| \--- org.springframework:spring-core:4.2.4.RELEASE
+--- org.mockito:mockito-core:2.0.41-beta -> 1.10.19
| +--- org.hamcrest:hamcrest-core:1.1 -> 1.3
| \--- org.objenesis:objenesis:2.1
\--- org.assertj:assertj-core:3.3.0
Wenn ich aus der Gleichung, die die Feder Boot-Plugin nehmen, die Dinge funktionieren wie erwartet:
# ./gradlew :main:dependencies --configuration=testCompile
testCompile - Compile classpath for source set 'test'.
+--- project :test-utils
+--- org.springframework:spring-core:4.2.4.RELEASE (*)
+--- org.springframework:spring-test:4.2.4.RELEASE
| \--- org.springframework:spring-core:4.2.4.RELEASE (*)
+--- junit:junit:4.12
+--- org.mockito:mockito-core:2.0.41-beta
| +--- net.bytebuddy:byte-buddy:1.0.2
| \--- org.objenesis:objenesis:2.1
\--- org.assertj:assertj-core:3.3.0
Was ist die Feder-Boot-Plugin genau tun, und wie kann ich sagen, es nicht zu tun?
Ich wusste einfach, die Antwort würde ein „wie in der Dokumentation beschrieben“ Hit ...: - /. Ich habe viel mit "Spring Boot Gradle" gesucht, aber jetzt, da ich weiß, dass die Antwort unter "Build" ist, merke ich, dass [dies] (https://github.com/spring-gradle-plugins/dependency-management-plugin/ # override-versions-in-bom) ist einen Klick entfernt von [hier] (https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-gradle- plugin.html). Seufzer. –