1

I have a spring boot project that depends on one of the 3rd party SDK libraries which contains a YAML file with some google cloud URLs.

I want to override those values within my YAML, this works for most of my project but for some reason no luck with this perticular dependency lib.

The Dependency Code

@ConfigurationProperties("google")
public class GoogleProperties {
 String url;
..
..
}

Yaml file application-google-prod.yaml

google:
     url: some url.

Say this is in a jar called google-client-sdk-1.0.0

My Code

Yaml file application-myapp-prod.yaml

spring:
  profiles:
    include: google-prod

google:
     url: OVERRIDE url.

So I am expecting that the OVERRIDE url should be used when the code in the lib is invoked, but instead it continues to use some url from jar file's yaml.

any pointers?

EDIT

The SDK contains another class class with the following annotations in the SDK

       @Configuation
       @PropertySource({"classpath:application-google-prod.yaml})

I think this is forcing SDK to pick the value from the specific YAML ignoring overridden value in the YAML from my app.

No_One
  • 215
  • 2
  • 3
  • 11

1 Answers1

0

Disclaimer:

A is have no mean reproducing your issue, this is just a suggestion.


Notice the absence of @Configuration on GoogleProperties.

You have to either add @Configuration on the properties class: (impossible in this case) or add @EnableConfigurationProperties(GoogleProperties.class) on top of the class where you want to use the properties.

E.g: Your main class if you want to use them in all the app.

As mentioned in the docs, you can also use:
@ConfigurationPropertiesScan({ "com.google.SDK", "org.acme.another" }) on top of your main class or any @Configuration class where you need those props.

Note: As explained here, the fact that as of spring-boot 2.2 we didn't need any more @Configuration or @EnableConfigurationProperties for the configuration properties feature is outdated.

Philippe Simo
  • 1,353
  • 1
  • 15
  • 28
  • Thanks for your reply Philippe. No luck with those options. But I think I might have found the issue. there is another class with the following annotations in the SDK @Configuation @PropertySource({"classpath:application--google-prod.yaml}) I think this forcing SDK to pick the value from the specific YAML ignoring YAML from my app. – No_One Mar 07 '21 at 11:26