spring property-placeholder总是给出默认值

时间:2017-06-14 04:08:31

标签: spring

在下面的示例中,我发现sampleWeight始终被视为默认值0.0,而不管placeHolder中的任何值。如果我删除默认值,那么它会选择正确的placeHolder值。

@Configuration
public class XYZConfiguration {

@Value("${properties.xyz:0.0}")
private double sampleWeightWithDefault;

@Value("${{properties.xyz}")
private double sampleWeight;

@Bean(initMethod = "start", destroyMethod = "stop")
Profile profiler() {
  LOGGER.error("sampleWeightWithDefault:" + sampleWeightWithDefault);
  LOGGER.error("sampleWeight:" + sampleWeight);
  return new Profile(sampleWeight);
}

O / P: sampleWeightWithDefault:0.0 sampleWeight:1.0

0 个答案:

没有答案