spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
704 stars 694 forks source link

Problem with autoconfiguration of SecretManagerTemplate when using Spring Cloud GCP Secret Manager starter #2612

Closed LiamWilson94 closed 3 years ago

LiamWilson94 commented 3 years ago

Hi šŸ‘‹

I am using Spring Boot WebFlux version 2.4.0 with the following Spring Cloud version and Spring Cloud GCP versions respectively


org.springframework.cloud:spring-cloud-dependencies:2020.0.0-M5
org.springframework.cloud:spring-cloud-gcp-dependencies:1.2.6.RELEASE

I am having difficulty being able to autowire the SecretManagerTemplate bean as it is not being created and I don't see the GcpSecretManagerBootstrapConfiguration class being autoconfigured.

Consider defining a bean of type 'org.springframework.cloud.gcp.secretmanager.SecretManagerTemplate' in your configuration.

My application.properties and bootstrap.properties (which are identical due to testing this out) are -

spring.cloud.gcp.projectId=1035281157226
spring.cloud.gcp.credentials.location=classpath:threadneedle-dev-2-7f7162f742cc.json
spring.cloud.gcp.secretmanager.projectId=1035281157226
spring.cloud.gcp.secretmanager.credentials.location=classpath:threadneedle-dev-2-7f7162f742cc.json
spring.cloud.gcp.secretmanager.enabled=true
spring.cloud.gcp.secretmanager.bootstrap.enabled=true

My full build.gradle is as follows

plugins {
    id 'org.springframework.boot' version '2.4.0'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'java'
}

group = 'io.threadneedle'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
    maven {
        url "https://repo.spring.io/milestone"
    }
    maven {
        url "https://repo.spring.io/release"
    }
}

dependencyManagement {
    imports {
        mavenBom 'org.springframework.cloud:spring-cloud-dependencies:2020.0.0-M5'
        mavenBom 'org.springframework.cloud:spring-cloud-gcp-dependencies:1.2.6.RELEASE'
    }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    implementation 'org.springframework.cloud:spring-cloud-gcp-starter-secretmanager'
    implementation 'org.springframework.cloud:spring-cloud-starter'
    implementation 'org.springframework.cloud:spring-cloud-context'
    compile 'commons-codec:commons-codec:1.11'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.projectreactor:reactor-test'
}

test {
    useJUnitPlatform()
}
ttomsu commented 3 years ago

Hi @LiamWilson94

Can you try com.google.cloud:spring-cloud-gcp-dependencies:2.0.0-RC2 with 2020.0.0-M5?

LiamWilson94 commented 3 years ago

Hi @ttomsu - really appreciate the speedy reply! Yes switching out to that worked a treat :)

compile group: 'com.google.cloud', name: 'spring-cloud-gcp-starter-secretmanager', version: '2.0.0-RC2'
compile group: 'com.google.cloud', name: 'spring-cloud-gcp-dependencies', version: '2.0.0-RC2', ext: 'pom'
meltsufin commented 3 years ago

1.2.x is only compatible with Spring Boot 2.3. For Spring Boot 2.4, you need to upgrade to 2.x which should have a GA release in a few weeks.