gpt4 book ai didi

spring-boot - 来自 Spring Boot 的 GCP secretmanager 抛出 ConverterNotFoundException

转载 作者:行者123 更新时间:2023-12-05 01:29:23 28 4
gpt4 key购买 nike

我正在尝试从应用引擎部署的 Spring Boot 应用程序访问 gcp secreetmanager,但我不断收到 org.springframework.core.convert.ConverterNotFoundException:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'com.example.email.EMailServiceApplication$HelloWorldController': Injection of autowired dependencies
failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter
found capable of converting from type [com.google.protobuf.ByteString$LiteralByteString] to type [java.lang.String]

当前的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>email-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>E-Mail Service</name>
<description>E-Mail Service für arktum</description>
<properties>
<java.version>11</java.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>1.2.8.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<version>1</version>
<projectId>GCLOUD_CONFIG</projectId>
</configuration>
</plugin>
</plugins>
</build>

</project>

还有主类:

@SpringBootApplication
public class EMailServiceApplication {

public static void main(String[] args) {
SpringApplication.run(EMailServiceApplication.class, args);
}

@RestController
class HelloWorldController {

@Value("${sm://greeting-prod}")
private String greeting;

@GetMapping("/")
public String hello() {
return this.greeting;
}
}
}

没有额外的配置属性,例如应用程序.properties。是否缺少任何依赖项?

最佳答案

根据 https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/490 Cloud GCP 与 Spring Boot 2.5.x 不兼容:

We have not upgraded Spring Cloud GCP to Spring Boot 2.5 compatibility (#472). I'll be looking at the upgrade blockers this week.

如果您使用 Spring Initializr Spring Boote 2.5.x 和 GCP 的组合被阻止了——你必须坚持使用工作正常的 2.4.7。

关于spring-boot - 来自 Spring Boot 的 GCP secretmanager 抛出 ConverterNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67803000/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com