弹簧靴1.x不使用gcloud Secrets Manager

发布于 2025-01-22 20:24:51 字数 2024 浏览 0 评论 0原文

我正在尝试将GCLoud Secret Manager添加到旧的1.5.2弹簧启动版本中,但我遇到了一些问题。

我尝试添加两个版本,但它们都没有用。

 implementation("org.springframework.cloud:spring-cloud-gcp-starter-secretmanager:1.2.2.RELEASE")
implementation 'com.google.cloud:spring-cloud-gcp-starter-secretmanager:3.1.0'

我正在收到错误:

java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Class;)V
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:186)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
at com.johnlewis.contactcentre.Application$Companion.main(Application.kt:48)
at com.johnlewis.contactcentre.Application.main(Application.kt)

因此,据我了解,我将春季云1.x的依赖性与2.x混合在一起,但我不确定如何解决此问题并在此版本的Spring上使用Secret Manager 。

如果您有任何想法,我会很感激。

谢谢

I'm trying to add gcloud secret manager to an old 1.5.2 Spring-boot version but I encountered some problems.

I've tried adding both and some other versions but none of them worked.

 implementation("org.springframework.cloud:spring-cloud-gcp-starter-secretmanager:1.2.2.RELEASE")
implementation 'com.google.cloud:spring-cloud-gcp-starter-secretmanager:3.1.0'

I'm receiving the error:

java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Class;)V
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:186)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
at com.johnlewis.contactcentre.Application$Companion.main(Application.kt:48)
at com.johnlewis.contactcentre.Application.main(Application.kt)

So, as far as I understood I'm mixing the dependency for spring cloud 1.x with 2.x but I'm not sure how to solve this and use the secret manager on this version of spring.

If you have any idea I would appreciate.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盛夏尉蓝 2025-01-29 20:24:51

要使用Spring Boot和AWS Secrets Manager,请使用官方 AWS SDK进行Java V2 。也就是说,使用。 (org.springframework.cloud:spring-cloud-cloud-gcp-starter-secretmanager不是Amazon API)

,就Spring Boot而言,使用:使用:

  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

将AWS SDK用于Java V2,Spring Boot效果很好。如果您不熟悉使用SecretSmanagerClient,请在此处查看代码示例:

https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/main/main/javav2/example_code_code/secretsmanager

如果您不知道如何与Java V2 API一起工作,请参阅:

开始Java 2.x的SDK

Amazon建议使用SDK的V2版本:

Java 2.x的AWS SDK是1.x版本代码库的主要重写。它建在Java 8+之上,并添加了几个经常要求的功能。其中包括对非阻滞I/O的支持以及在运行时插入其他HTTP实现的能力。

V2的好处是非块异步调用。使用Spring Boot时,您可以编写异步代码。这是 aws sns dev指南 的一个示例呼叫。

To use Spring Boot and AWS Secrets Manager, use the official AWS SDK for Java V2. That is, use Interface SecretsManagerClient. (org.springframework.cloud:spring-cloud-gcp-starter-secretmanager is not an Amazon API)

As far as Spring Boot, use:

  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

Using the AWS SDK for Java v2 and Spring Boot works well. If you are not familiar with using SecretsManagerClient, look at the code examples here:

https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/secretsmanager

If you do not know how to work with the Java V2 API, see:

Get started with the AWS SDK for Java 2.x

Amazon recommends using the v2 version of the SDK:

The AWS SDK for Java 2.x is a major rewrite of the version 1.x code base. It’s built on top of Java 8+ and adds several frequently requested features. These include support for non-blocking I/O and the ability to plug in a different HTTP implementation at run time.

A benefit of V2 is non-blocking Async calls. You can write Async code when working with Spring Boot. Here is an example in the AWS SNS DEV Guide that shows you How To use AWS SDK for Java v2 Async calls.

Build a publish and subscription application that translates messages

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文