如何在XML中使用SpringJava属性默认值

如何在XML中使用SpringJava属性默认值,java,spring,spring-boot,properties,configurationproperty,Java,Spring,Spring Boot,Properties,Configurationproperty,我正在研究如何在XML中使用Java默认属性值,而无需在应用程序YML中指定 这是我的java配置,默认情况下,在从YML文件提供URL值之前,我希望使用该URL值 @EnableConfigurationProperties @ConfigurationProperties(prefix = "test.sample") public @Data class SampleProperties { private String serverurl ="test.example.com";

我正在研究如何在XML中使用Java默认属性值,而无需在应用程序YML中指定

这是我的java配置,默认情况下,在从YML文件提供URL值之前,我希望使用该URL值

@EnableConfigurationProperties
@ConfigurationProperties(prefix = "test.sample")
public @Data class SampleProperties {
   private String serverurl ="test.example.com";
}
当我尝试在XML中使用

<property name="serverURL" value="${test.sample.serverurl}" />

在XML中使用占位符时,不包括缺少占位符时要使用的默认值

可以在占位符上使用
:Default value
后缀提供默认值

<property name="serverURL" value="${test.sample.serverurl:http://localhost}" />
可能有一个复制品。这是一本书

<property name="serverURL" value="${test.sample.serverurl:http://localhost}" />
value="example:default"
value="test.sample.port:8080"