In an effort to put together an example project for Spring Cloud Config server and (Java and non-Java) clients using Vault, I decided to go the route of a multi-module Gradle build. Since I already had two working Java projects (server and client), I figured that I could pull the common configuration up into the parent build.gradle
and conditionally apply the configuration for the Java subprojects. I started with the server subproject, and ran into an issue that I've been unable to resolve.
The build.gradle
for the parent module looks like:
plugins {
id 'org.springframework.boot' version '2.3.0.RELEASE' apply false
id 'io.spring.dependency-management' version '1.0.9.RELEASE' apply false
id 'idea'
}
ext {
set('springCloudVersion', "Hoxton.SR4")
}
allprojects {
repositories {
mavenCentral()
}
version = '0.0.1-SNAPSHOT'
}
subprojects {
// We'll need dependencies for Docker and Docker compose
afterEvaluate { project ->
if (project.usesSpringBoot) {
println("Configuring ${springCloudVersion}")
configure(project) {
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
group = 'com.daecabhir'
sourceCompatibility = '11'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
test {
useJUnitPlatform()
}
}
}
}
}
and the build.gradle
for the cloud-config-server
subproject looks like:
ext {
usesSpringBoot = true
}
Unfortunately attempting a ./gradlew build
leaves me with an error that it cannot find a class from Spring Cloud Config:
/home/gwright/projects/cloud-config-vault-example/cloud-config-server/src/main/java/com/daecabhir/cloudconfigserver/CloudConfigServerApplication.java:5: error: package org.springframework.cloud.config.server does not exist
import org.springframework.cloud.config.server.EnableConfigServer;
^
/home/gwright/projects/cloud-config-vault-example/cloud-config-server/src/main/java/com/daecabhir/cloudconfigserver/CloudConfigServerApplication.java:7: error: cannot find symbol
@EnableConfigServer
^
symbol: class EnableConfigServer
2 errors
When I check the dependencies, I get the following for compile time:
compileClasspath - Compile classpath for source set 'main'.
+--- org.springframework.boot:spring-boot-starter-actuator -> 2.3.0.RELEASE
| +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE
| | +--- com.fasterxml.jackson.core:jackson-databind:2.11.0 (c)
| | +--- io.micrometer:micrometer-core:1.5.1 (c)
| | +--- org.springframework:spring-web:5.2.6.RELEASE (c)
| | +--- org.springframework:spring-webmvc:5.2.6.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-actuator-autoconfigure:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter-actuator:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter-json:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter-tomcat:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter-web:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-autoconfigure:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter-logging:2.3.0.RELEASE (c)
| | +--- jakarta.annotation:jakarta.annotation-api:1.3.5 (c)
| | +--- org.springframework:spring-core:5.2.6.RELEASE (c)
| | +--- org.yaml:snakeyaml:1.26 (c)
| | +--- org.springframework.boot:spring-boot-actuator:2.3.0.RELEASE (c)
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.0 (c)
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.0 (c)
| | +--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.0 (c)
| | +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.35 (c)
| | +--- org.glassfish:jakarta.el:3.0.3 (c)
| | +--- org.apache.tomcat.embed:tomcat-embed-websocket:9.0.35 (c)
| | +--- org.springframework:spring-beans:5.2.6.RELEASE (c)
| | +--- org.springframework:spring-aop:5.2.6.RELEASE (c)
| | +--- org.springframework:spring-context:5.2.6.RELEASE (c)
| | +--- org.springframework:spring-expression:5.2.6.RELEASE (c)
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.11.0 (c)
| | +--- com.fasterxml.jackson.core:jackson-core:2.11.0 (c)
| | +--- ch.qos.logback:logback-classic:1.2.3 (c)
| | +--- org.apache.logging.log4j:log4j-to-slf4j:2.13.2 (c)
| | +--- org.slf4j:jul-to-slf4j:1.7.30 (c)
| | +--- org.springframework:spring-jcl:5.2.6.RELEASE (c)
| | +--- org.springframework.security:spring-security-crypto:5.3.2.RELEASE (c)
| | +--- ch.qos.logback:logback-core:1.2.3 (c)
| | +--- org.slf4j:slf4j-api:1.7.30 (c)
| | \--- org.apache.logging.log4j:log4j-api:2.13.2 (c)
| +--- org.springframework.boot:spring-boot-starter:2.3.0.RELEASE
| | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | +--- org.springframework.boot:spring-boot:2.3.0.RELEASE
| | | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | | +--- org.springframework:spring-core -> 5.2.6.RELEASE
| | | | \--- org.springframework:spring-jcl:5.2.6.RELEASE
| | | \--- org.springframework:spring-context -> 5.2.6.RELEASE
| | | +--- org.springframework:spring-aop:5.2.6.RELEASE
| | | | +--- org.springframework:spring-beans:5.2.6.RELEASE
| | | | | \--- org.springframework:spring-core:5.2.6.RELEASE (*)
| | | | \--- org.springframework:spring-core:5.2.6.RELEASE (*)
| | | +--- org.springframework:spring-beans:5.2.6.RELEASE (*)
| | | +--- org.springframework:spring-core:5.2.6.RELEASE (*)
| | | \--- org.springframework:spring-expression:5.2.6.RELEASE
| | | \--- org.springframework:spring-core:5.2.6.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-autoconfigure:2.3.0.RELEASE
| | | +--- org.springframework.boot:spring-boot:2.3.0.RELEASE (*)
| | | \--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-starter-logging:2.3.0.RELEASE
| | | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | | +--- ch.qos.logback:logback-classic -> 1.2.3
| | | | +--- ch.qos.logback:logback-core:1.2.3
| | | | \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
| | | +--- org.apache.logging.log4j:log4j-to-slf4j -> 2.13.2
| | | | +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
| | | | \--- org.apache.logging.log4j:log4j-api:2.13.2
| | | \--- org.slf4j:jul-to-slf4j -> 1.7.30
| | | \--- org.slf4j:slf4j-api:1.7.30
| | +--- jakarta.annotation:jakarta.annotation-api -> 1.3.5
| | +--- org.springframework:spring-core -> 5.2.6.RELEASE (*)
| | \--- org.yaml:snakeyaml -> 1.26
| +--- org.springframework.boot:spring-boot-actuator-autoconfigure:2.3.0.RELEASE
| | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | \--- org.springframework.boot:spring-boot-actuator:2.3.0.RELEASE
| | \--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| \--- io.micrometer:micrometer-core -> 1.5.1
| \--- org.hdrhistogram:HdrHistogram:2.1.12
+--- org.springframework.boot:spring-boot-starter-web -> 2.3.0.RELEASE
| +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| +--- org.springframework.boot:spring-boot-starter:2.3.0.RELEASE (*)
| +--- org.springframework.boot:spring-boot-starter-json:2.3.0.RELEASE
| | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-starter:2.3.0.RELEASE (*)
| | +--- org.springframework:spring-web -> 5.2.6.RELEASE
| | | +--- org.springframework:spring-beans:5.2.6.RELEASE (*)
| | | \--- org.springframework:spring-core:5.2.6.RELEASE (*)
| | +--- com.fasterxml.jackson.core:jackson-databind -> 2.11.0
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.11.0
| | | \--- com.fasterxml.jackson.core:jackson-core:2.11.0
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8 -> 2.11.0
| | | +--- com.fasterxml.jackson.core:jackson-core:2.11.0
| | | \--- com.fasterxml.jackson.core:jackson-databind:2.11.0 (*)
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310 -> 2.11.0
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.11.0
| | | +--- com.fasterxml.jackson.core:jackson-core:2.11.0
| | | \--- com.fasterxml.jackson.core:jackson-databind:2.11.0 (*)
| | \--- com.fasterxml.jackson.module:jackson-module-parameter-names -> 2.11.0
| | +--- com.fasterxml.jackson.core:jackson-core:2.11.0
| | \--- com.fasterxml.jackson.core:jackson-databind:2.11.0 (*)
| +--- org.springframework.boot:spring-boot-starter-tomcat:2.3.0.RELEASE
| | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | +--- jakarta.annotation:jakarta.annotation-api -> 1.3.5
| | +--- org.apache.tomcat.embed:tomcat-embed-core -> 9.0.35
| | +--- org.glassfish:jakarta.el -> 3.0.3
| | \--- org.apache.tomcat.embed:tomcat-embed-websocket -> 9.0.35
| | \--- org.apache.tomcat.embed:tomcat-embed-core:9.0.35
| +--- org.springframework:spring-web -> 5.2.6.RELEASE (*)
| \--- org.springframework:spring-webmvc -> 5.2.6.RELEASE
| +--- org.springframework:spring-aop:5.2.6.RELEASE (*)
| +--- org.springframework:spring-beans:5.2.6.RELEASE (*)
| +--- org.springframework:spring-context:5.2.6.RELEASE (*)
| +--- org.springframework:spring-core:5.2.6.RELEASE (*)
| +--- org.springframework:spring-expression:5.2.6.RELEASE (*)
| \--- org.springframework:spring-web:5.2.6.RELEASE (*)
\--- org.springframework.cloud:spring-cloud-starter-config -> 2.2.2.RELEASE
+--- org.springframework.cloud:spring-cloud-starter:2.2.2.RELEASE
| +--- org.springframework.boot:spring-boot-starter:2.2.5.RELEASE -> 2.3.0.RELEASE (*)
| +--- org.springframework.cloud:spring-cloud-context:2.2.2.RELEASE
| | \--- org.springframework.security:spring-security-crypto:5.2.2.RELEASE -> 5.3.2.RELEASE
| +--- org.springframework.cloud:spring-cloud-commons:2.2.2.RELEASE
| | \--- org.springframework.security:spring-security-crypto:5.2.2.RELEASE -> 5.3.2.RELEASE
| \--- org.springframework.security:spring-security-rsa:1.0.9.RELEASE
| \--- org.bouncycastle:bcpkix-jdk15on:1.64
| \--- org.bouncycastle:bcprov-jdk15on:1.64
+--- org.springframework.cloud:spring-cloud-config-client:2.2.2.RELEASE
| +--- org.springframework.boot:spring-boot-autoconfigure:2.2.5.RELEASE -> 2.3.0.RELEASE (*)
| +--- org.springframework.cloud:spring-cloud-commons:2.2.2.RELEASE (*)
| +--- org.springframework.cloud:spring-cloud-context:2.2.2.RELEASE (*)
| +--- org.springframework:spring-web:5.2.4.RELEASE -> 5.2.6.RELEASE (*)
| +--- com.fasterxml.jackson.core:jackson-annotations:2.10.2 -> 2.11.0
| \--- com.fasterxml.jackson.core:jackson-databind:2.10.2 -> 2.11.0 (*)
\--- com.fasterxml.jackson.core:jackson-databind:2.10.2 -> 2.11.0 (*)
which on the face of it looks reasonable, except that it isn't. It seems that Gradle is honoring the dependencies, but they are not getting fully resolved by dependency management. When I fall back to fully specifying the configuration in the cloud-config-server
subproject using the following parent build.gradle
:
plugins {
id 'org.springframework.boot' version '2.3.0.RELEASE' apply false
id 'io.spring.dependency-management' version '1.0.9.RELEASE' apply false
id 'idea'
}
ext {
set('springCloudVersion', "Hoxton.SR4")
}
allprojects {
repositories {
mavenCentral()
}
version = '0.0.1-SNAPSHOT'
}
and a subproject build.gradle
of:
plugins {
id 'org.springframework.boot'
id 'io.spring.dependency-management'
id 'java'
}
group = 'com.daecabhir'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-config-server'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
test {
useJUnitPlatform()
}
the build works fine, and the dependencies are more fully "resolved" (the spring-cloud-config-server dependency in particular):
compileClasspath - Compile classpath for source set 'main'.
+--- org.springframework.boot:spring-boot-starter-web -> 2.3.0.RELEASE
| +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE
| | +--- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11.0 (c)
| | +--- org.springframework:spring-web:5.2.6.RELEASE (c)
| | +--- org.springframework:spring-webmvc:5.2.6.RELEASE (c)
| | +--- org.springframework.security:spring-security-crypto:5.3.2.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter-actuator:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter-json:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter-tomcat:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter-validation:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter-web:2.3.0.RELEASE (c)
| | +--- org.yaml:snakeyaml:1.26 (c)
| | +--- org.springframework.boot:spring-boot:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-autoconfigure:2.3.0.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-starter-logging:2.3.0.RELEASE (c)
| | +--- jakarta.annotation:jakarta.annotation-api:1.3.5 (c)
| | +--- org.springframework:spring-core:5.2.6.RELEASE (c)
| | +--- com.fasterxml.jackson.core:jackson-databind:2.11.0 (c)
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.0 (c)
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.0 (c)
| | +--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.0 (c)
| | +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.35 (c)
| | +--- org.glassfish:jakarta.el:3.0.3 (c)
| | +--- org.apache.tomcat.embed:tomcat-embed-websocket:9.0.35 (c)
| | +--- org.springframework:spring-beans:5.2.6.RELEASE (c)
| | +--- org.springframework:spring-aop:5.2.6.RELEASE (c)
| | +--- org.springframework:spring-context:5.2.6.RELEASE (c)
| | +--- org.springframework:spring-expression:5.2.6.RELEASE (c)
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.11.0 (c)
| | +--- org.springframework.boot:spring-boot-actuator-autoconfigure:2.3.0.RELEASE (c)
| | +--- io.micrometer:micrometer-core:1.5.1 (c)
| | +--- org.hibernate.validator:hibernate-validator:6.1.5.Final (c)
| | +--- org.slf4j:slf4j-api:1.7.30 (c)
| | +--- org.apache.httpcomponents:httpclient:4.5.12 (c)
| | +--- org.apache.httpcomponents:httpcore:4.4.13 (c)
| | +--- com.fasterxml.jackson.core:jackson-core:2.11.0 (c)
| | +--- ch.qos.logback:logback-classic:1.2.3 (c)
| | +--- org.apache.logging.log4j:log4j-to-slf4j:2.13.2 (c)
| | +--- org.slf4j:jul-to-slf4j:1.7.30 (c)
| | +--- org.springframework:spring-jcl:5.2.6.RELEASE (c)
| | +--- org.springframework.boot:spring-boot-actuator:2.3.0.RELEASE (c)
| | +--- jakarta.validation:jakarta.validation-api:2.0.2 (c)
| | +--- org.jboss.logging:jboss-logging:3.4.1.Final (c)
| | +--- com.fasterxml:classmate:1.5.1 (c)
| | +--- commons-codec:commons-codec:1.14 (c)
| | +--- ch.qos.logback:logback-core:1.2.3 (c)
| | \--- org.apache.logging.log4j:log4j-api:2.13.2 (c)
| +--- org.springframework.boot:spring-boot-starter:2.3.0.RELEASE
| | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | +--- org.springframework.boot:spring-boot:2.3.0.RELEASE
| | | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | | +--- org.springframework:spring-core -> 5.2.6.RELEASE
| | | | \--- org.springframework:spring-jcl:5.2.6.RELEASE
| | | \--- org.springframework:spring-context -> 5.2.6.RELEASE
| | | +--- org.springframework:spring-aop:5.2.6.RELEASE
| | | | +--- org.springframework:spring-beans:5.2.6.RELEASE
| | | | | \--- org.springframework:spring-core:5.2.6.RELEASE (*)
| | | | \--- org.springframework:spring-core:5.2.6.RELEASE (*)
| | | +--- org.springframework:spring-beans:5.2.6.RELEASE (*)
| | | +--- org.springframework:spring-core:5.2.6.RELEASE (*)
| | | \--- org.springframework:spring-expression:5.2.6.RELEASE
| | | \--- org.springframework:spring-core:5.2.6.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-autoconfigure:2.3.0.RELEASE
| | | +--- org.springframework.boot:spring-boot:2.3.0.RELEASE (*)
| | | \--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-starter-logging:2.3.0.RELEASE
| | | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | | +--- ch.qos.logback:logback-classic -> 1.2.3
| | | | +--- ch.qos.logback:logback-core:1.2.3
| | | | \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
| | | +--- org.apache.logging.log4j:log4j-to-slf4j -> 2.13.2
| | | | +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
| | | | \--- org.apache.logging.log4j:log4j-api:2.13.2
| | | \--- org.slf4j:jul-to-slf4j -> 1.7.30
| | | \--- org.slf4j:slf4j-api:1.7.30
| | +--- jakarta.annotation:jakarta.annotation-api -> 1.3.5
| | +--- org.springframework:spring-core -> 5.2.6.RELEASE (*)
| | \--- org.yaml:snakeyaml -> 1.26
| +--- org.springframework.boot:spring-boot-starter-json:2.3.0.RELEASE
| | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-starter:2.3.0.RELEASE (*)
| | +--- org.springframework:spring-web -> 5.2.6.RELEASE
| | | +--- org.springframework:spring-beans:5.2.6.RELEASE (*)
| | | \--- org.springframework:spring-core:5.2.6.RELEASE (*)
| | +--- com.fasterxml.jackson.core:jackson-databind -> 2.11.0
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.11.0
| | | \--- com.fasterxml.jackson.core:jackson-core:2.11.0
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8 -> 2.11.0
| | | +--- com.fasterxml.jackson.core:jackson-core:2.11.0
| | | \--- com.fasterxml.jackson.core:jackson-databind:2.11.0 (*)
| | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310 -> 2.11.0
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.11.0
| | | +--- com.fasterxml.jackson.core:jackson-core:2.11.0
| | | \--- com.fasterxml.jackson.core:jackson-databind:2.11.0 (*)
| | \--- com.fasterxml.jackson.module:jackson-module-parameter-names -> 2.11.0
| | +--- com.fasterxml.jackson.core:jackson-core:2.11.0
| | \--- com.fasterxml.jackson.core:jackson-databind:2.11.0 (*)
| +--- org.springframework.boot:spring-boot-starter-tomcat:2.3.0.RELEASE
| | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | +--- jakarta.annotation:jakarta.annotation-api -> 1.3.5
| | +--- org.apache.tomcat.embed:tomcat-embed-core -> 9.0.35
| | +--- org.glassfish:jakarta.el -> 3.0.3
| | \--- org.apache.tomcat.embed:tomcat-embed-websocket -> 9.0.35
| | \--- org.apache.tomcat.embed:tomcat-embed-core:9.0.35
| +--- org.springframework:spring-web -> 5.2.6.RELEASE (*)
| \--- org.springframework:spring-webmvc -> 5.2.6.RELEASE
| +--- org.springframework:spring-aop:5.2.6.RELEASE (*)
| +--- org.springframework:spring-beans:5.2.6.RELEASE (*)
| +--- org.springframework:spring-context:5.2.6.RELEASE (*)
| +--- org.springframework:spring-core:5.2.6.RELEASE (*)
| +--- org.springframework:spring-expression:5.2.6.RELEASE (*)
| \--- org.springframework:spring-web:5.2.6.RELEASE (*)
\--- org.springframework.cloud:spring-cloud-config-server -> 2.2.2.RELEASE
+--- org.springframework.cloud:spring-cloud-config-client:2.2.2.RELEASE
| +--- org.springframework.boot:spring-boot-autoconfigure:2.2.5.RELEASE -> 2.3.0.RELEASE (*)
| +--- org.springframework.cloud:spring-cloud-commons:2.2.2.RELEASE
| | \--- org.springframework.security:spring-security-crypto:5.2.2.RELEASE -> 5.3.2.RELEASE
| +--- org.springframework.cloud:spring-cloud-context:2.2.2.RELEASE
| | \--- org.springframework.security:spring-security-crypto:5.2.2.RELEASE -> 5.3.2.RELEASE
| +--- org.springframework:spring-web:5.2.4.RELEASE -> 5.2.6.RELEASE (*)
| +--- com.fasterxml.jackson.core:jackson-annotations:2.10.2 -> 2.11.0
| \--- com.fasterxml.jackson.core:jackson-databind:2.10.2 -> 2.11.0 (*)
+--- org.springframework.boot:spring-boot-starter-actuator:2.2.5.RELEASE -> 2.3.0.RELEASE
| +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| +--- org.springframework.boot:spring-boot-starter:2.3.0.RELEASE (*)
| +--- org.springframework.boot:spring-boot-actuator-autoconfigure:2.3.0.RELEASE
| | +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| | \--- org.springframework.boot:spring-boot-actuator:2.3.0.RELEASE
| | \--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| \--- io.micrometer:micrometer-core -> 1.5.1
| \--- org.hdrhistogram:HdrHistogram:2.1.12
+--- org.springframework.boot:spring-boot-starter-web:2.2.5.RELEASE -> 2.3.0.RELEASE (*)
+--- org.springframework.boot:spring-boot-starter-validation:2.2.5.RELEASE -> 2.3.0.RELEASE
| +--- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE (*)
| +--- org.springframework.boot:spring-boot-starter:2.3.0.RELEASE (*)
| +--- org.glassfish:jakarta.el -> 3.0.3
| \--- org.hibernate.validator:hibernate-validator -> 6.1.5.Final
| +--- jakarta.validation:jakarta.validation-api:2.0.2
| +--- org.jboss.logging:jboss-logging:3.3.2.Final -> 3.4.1.Final
| \--- com.fasterxml:classmate:1.3.4 -> 1.5.1
+--- org.springframework.security:spring-security-crypto:5.2.2.RELEASE -> 5.3.2.RELEASE
+--- org.springframework.security:spring-security-rsa:1.0.9.RELEASE
| \--- org.bouncycastle:bcpkix-jdk15on:1.64
| \--- org.bouncycastle:bcprov-jdk15on:1.64
+--- org.eclipse.jgit:org.eclipse.jgit:5.1.3.201810200350-r
| +--- com.jcraft:jsch:0.1.54
| +--- com.jcraft:jzlib:1.1.1
| +--- com.googlecode.javaewah:JavaEWAH:1.1.6
| \--- org.slf4j:slf4j-api:1.7.2 -> 1.7.30
+--- org.eclipse.jgit:org.eclipse.jgit.http.apache:5.1.3.201810200350-r
| +--- org.eclipse.jgit:org.eclipse.jgit:5.1.3.201810200350-r (*)
| +--- org.apache.httpcomponents:httpclient:4.5.5 -> 4.5.12
| | +--- org.apache.httpcomponents:httpcore:4.4.13
| | \--- commons-codec:commons-codec:1.11 -> 1.14
| \--- org.apache.httpcomponents:httpcore:4.4.9 -> 4.4.13
+--- org.yaml:snakeyaml:1.25 -> 1.26
\--- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.10.2 -> 2.11.0
+--- com.fasterxml.jackson.core:jackson-databind:2.11.0 (*)
+--- org.yaml:snakeyaml:1.26
\--- com.fasterxml.jackson.core:jackson-core:2.11.0
So my question is, what do I need to do in order to be able to specify the configuration in the parent project selectively based on a property so that the dependencies will be fully resolved? And what is it about how I specified the configuration that is causing it to not fully resolve the dependencies?
FWIW, the full code for the project can be found here:
I've made a PR to your repo: https://github.com/daecabhir/cloud-config-vault-example/pull/3
Rather than using a property to control if a project is a Spring Boot project (didn't work for me), you can define a list of projects that are Spring Boot based projects, then apply defaults which you have done.
plugins {
id 'org.springframework.boot' version '2.3.0.RELEASE' apply false
id 'io.spring.dependency-management' version '1.0.9.RELEASE' apply false
id 'idea'
}
ext {
set('springCloudVersion', "Hoxton.SR4")
}
allprojects {
repositories {
mavenCentral()
}
version = '0.0.1-SNAPSHOT'
}
// List of Spring Boot based projects
def springBootProjects = [
project(":cloud-config-server"),
project(":cloud-config-client")
]
Once you have your list, then simply iterate over them, applying based configuration to them:
springBootProjects.each { springBootProject ->
configure(springBootProject) {
println("Configuring $name as a Spring Boot project")
apply {
plugin("org.springframework.boot")
plugin("io.spring.dependency-management")
plugin("java")
}
group = "com.daecabhir"
sourceCompatibility = "11"
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
tasks {
test {
useJUnitPlatform()
}
}
}
}
You had spring-cloud-starter-config
as an import for the server application, but that is incorrect because the spring-cloud-starter-config
module brings in spring-cloud-config-client
which is not what is needed for a config server as it leads to import issues.
So rather than defining the dependency there as a base dependency, move it to the project itself:
cloud-config-server/build.gradle
dependencies {
implementation "org.springframework.cloud:spring-cloud-config-server"
}
cloud-config-client/build.gradle
dependencies {
implementation "org.springframework.cloud:spring-cloud-starter-config"
}
With these changes, the resulting output is:
$ ./gradlew assemble
> Configure project :
Configuring cloud-config-server as a Spring Boot project
Configuring cloud-config-client as a Spring Boot project
BUILD SUCCESSFUL in 2s
6 actionable tasks: 6 up-to-date