Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring YAML how a property can refer another property of object type

Tags:

java

spring

yaml

I have a YAML file where a property has reference of another property.

E.g.:

sidh:
    sftp:
        profile1:
            host: xxxx.com
            local:
                directory:
                    download: localDownload
            user: abctest
            password: Team334


    sf:
      mf:
        clientId: 2324
        clientSecret: sd23
        refreshToken: 23sds
        url: test.salesforce.com

    feeds:
        mf_company:
          processor: com.xxxx.ABC
          pattern: ABC_*
          sf: mf   # How to reference sidh.sf.mf
          sft: profile1 # How to reference sidh.sftp.profile1 

I am using Spring and I couldn't find any out of the box library/examples about how a property (sidh.feeds.mf_company.sf or sft) can refer another object type property (sidh.sf.mf, sidh.sftp.profile1). I can write custom code to represent this YAML and create references.

My question is: are there any out of the box library available to handle this scenario?

like image 533
Rahul Sharma Avatar asked Nov 26 '25 19:11

Rahul Sharma


1 Answers

There is no out of the box solution for your scenario. YAML only supports a simple key-value dictionary without any object implementation.

If you wish to wish to use your configuration as an object, you need to create your own implementation like you said in your code.

like image 150
Stempler Avatar answered Nov 29 '25 10:11

Stempler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!