简体   繁体   中英

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.

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.).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM