简体   繁体   English

Spring Boot 1.x 无法与 Gcloud Secrets Manager 一起使用

[英]Spring Boot 1.x not working with Gcloud Secrets Manager

I'm trying to add gcloud secret manager to an old 1.5.2 Spring-boot version but I encountered some problems.我正在尝试将 gcloud secret manager 添加到旧的 1.5.2 Spring-boot 版本,但遇到了一些问题。

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.所以,据我了解,我正在混合 spring cloud 1.x 和 2.x 的依赖关系,但我不确定如何解决这个问题并在这个版本的 spring 上使用秘密管理器。

If you have any idea I would appreciate.如果您有任何想法,我将不胜感激。

Thanks谢谢

To use Spring Boot and AWS Secrets Manager, use the official AWS SDK for Java V2 .要使用 Spring Boot 和 AWS Secrets Manager,请使用官方AWS SDK for Java V2 That is, use Interface SecretsManagerClient .也就是说,使用接口 SecretsManagerClient (org.springframework.cloud:spring-cloud-gcp-starter-secretmanager is not an Amazon API) (org.springframework.cloud:spring-cloud-gcp-starter-secretmanager 不是亚马逊 API)

As far as Spring Boot, use:至于 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>

Using the AWS SDK for Java v2 and Spring Boot works well.使用 AWS SDK for Java v2 和 Spring Boot 效果很好。 If you are not familiar with using SecretsManagerClient, look at the code examples here:如果您不熟悉 SecretsManagerClient 的使用,请查看此处的代码示例:

https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/secretsmanager 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:如果您不知道如何使用 Java V2 API,请参阅:

Get started with the AWS SDK for Java 2.x 开始使用适用于 Java 2.x 的 AWS 开发工具包

Amazon recommends using the v2 version of the SDK:亚马逊建议使用 SDK 的 v2 版本:

The AWS SDK for Java 2.x is a major rewrite of the version 1.x code base. AWS SDK for Java 2.x 是对 1.x 版代码库的重大重写。 It's built on top of Java 8+ and adds several frequently requested features.它建立在 Java 8+ 之上,并添加了几个经常请求的特性。 These include support for non-blocking I/O and the ability to plug in a different HTTP implementation at run time.其中包括对非阻塞 I/O 的支持以及在运行时插入不同 HTTP 实现的能力。

A benefit of V2 is non-blocking Async calls. V2 的一个好处是非阻塞异步调用。 You can write Async code when working with Spring Boot.您可以在使用 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.这是AWS SNS 开发指南中的一个示例,它向您展示了如何使用AWS SDK for Java v2异步调用。

Build a publish and subscription application that translates messages 构建翻译消息的发布和订阅应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有 aws Secrets manager 的 spring boot 无法运行 - spring boot with aws secrets manager not able to run 在 Spring 引导中存储 AWS Secrets Manager 的 accessKey 和 secretKey 的位置 - Where to store the accessKey and secretKey for AWS Secrets Manager in Spring Boot 如何配置sessionListener使用spring boot 1.x. - How to configure sessionListener use spring boot 1.x Spring Boot 1.x,如何将指标增加一定数量 - Spring boot 1.x , How to increment a metric by an amount @Transactional在使用自定义事务管理器的Spring Boot中不起作用 - @Transactional not working in Spring Boot with a custom Transaction Manager 尝试从 spring 启动和区域错误中配置读取秘密管理器 - Trying to configure reading from secrets manager in spring boot and region error thrown 将 Spring 引导 1.x 升级到 2.x(如果使用 {cipher} 文本,则更新 ENCRYPT KEY VM 参数) - Upgrade Spring Boot 1.x to 2.x (update ENCRYPT KEY VM argument if using {cipher} texts) 针对供应商特定脚本的FlyWay + Spring Boot 2.x错误:使用1.x版发现了多个迁移 - FlyWay + Spring Boot 2.x for vendor specific scripts error: found more than one migration with version 1.x spring 引导 + gcloud +“502 错误网关” - spring boot + gcloud + "502 Bad Gateway" Spring安全认证和Ionic / Angular 1.X - Spring security authentication and Ionic/Angular 1.X
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM