在下面的示例中,我发现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