spring-data-jpa 如何在yml文件中将ByteString转换为String. GCP secret manager,spring Boot

iszxjhcz  于 2022-11-10  发布在  Spring
关注(0)|答案(1)|浏览(140)

我按照文档www.example.com进行操作https://docs.spring.io/spring-cloud-gcp/docs/current/reference/html/secretmanager.html#_secret_manager_property_source,bootstrap.yml文件如下所示:

spring:
   clouds:
     gcp:
       secret manager:
         enabled: true
         secret-name-prefix: "sm://"
         project-id: my-project-id
   data source:
     username: "${sm://datasource-username}"
     password: test

应用程序.yml文件如下所示:

spring:
   clouds:
     gcp:
       projectId: my-project-id
       SQL:
         instance-connection-name: "my-instance"
         databaseName: testDatabase

我得到了这个错误:

Property: spring.datasource.username\n Value: ${sm://datasource-username}\n Origin: class path resource [bootstrap.yml] - 9:15\n

Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [com.google.protobuf.ByteString$LiteralByteString] to type [java.lang.String]\n\nAction:\n\nUpdate your application's configuration\n"}

我真的不明白我做错了什么:(我想我需要一个转换器(. toStringUtf8())在bootstrap.yml,但我不知道如何实现一个转换器在yml文件.任何想法都是有帮助的,非常感谢

roejwanj

roejwanj1#

我使用了这个依赖关系,它起作用了:

implementation("com.google.cloud:spring-cloud-gcp-starter-secretmanager:3.2.1")

相关问题