Property in @ConfigurationProperties prefix

2019-09-19 07:46发布

问题:

Is it possible to use a property in

@ConfigurationProperties(prefix = "${domain}.user")

This doesn't work. I just want to "prefix the prefix" with the value from another property from the same properties file. For example:

domain=${domain}
domain1.user.username=john
domain2.user.username=irene

The full prefix wanted would be domain1.user after filtering using "domain1" as a value for the domain property.

回答1:

According to @ConfigurationProperties javadoc:

 * Note that contrary to {@code @Value}, SpEL expressions are not evaluated since property
 * values are externalized.