0

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

nekperu15739
  • 3,311
  • 2
  • 26
  • 25

1 Answers1

0

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

smac2020
  • 9,637
  • 4
  • 24
  • 38