plzdontkillme
plzdontkillme

Reputation: 1527

Spring boot @ConfigurationProperties prefix wildcard

I have multiple .yml

project: 
    module1:
      mysql:
        urls 

project: 
    module2:
      mysql: 
         urls: 

Than I have a generic MySQLClient which should be able to read values from both .yml files

Is it possible to do something like this

@Component
@ConfigurationProperties(prefix="project.*.mysql") 

or with @Value with the help of Spring EL Expression.

Any help or direction is appreciated.

Upvotes: 4

Views: 1875

Answers (1)

Regarding to this spring boot issue 1768 its is not possible to use SPEL in @ConfigurationProperties

Anyway, reading properties is done by spring once, on application startup. Normaly in that moment your MSQLClient, if intantiaded by spring, would not yet be available (no datasource available etc.).

Upvotes: 1

Related Questions