I am looking how to use the Java default properties value in XML without specifying in application YML or what ever.
This is my java configuration and default I want to use this URL value until providing it from YML file.
@EnableConfigurationProperties
@ConfigurationProperties(prefix = "test.sample")
public @Data class SampleProperties {
private String serverurl ="test.example.com";
}
When I try to use in XML
<property name="serverURL" value="${test.sample.serverurl}" />
Throwing
IllegalArgumentException : Could not resolve placeholder 'test.sample.serverurl' in value "${test.sample.serverurl}"
Your use of the placeholder in XML does not include a default value to use when it is missing
Default values can be provided with a
:default-value
suffix on the placeholderThe example is complicated by the
:
in the default value, simpler ones might beThere is a probable duplicate Is there a way to specify a default property value in Spring XML?. Here is a decent tutorial on properties in Spring.