I am working with Spring boot 1.1.8 which uses Spring 4.0.7. I am autowiring the properties in my classes with @Value annotation. I want to have a default value if the property is not present in properties file so, I use ":" to assign default value. Below is the example:
@Value("${custom.data.export:false}")
private boolean exportData = true;
It should assign false to the variable if property is not present in the properties file which is does. However, if property is present in the file, then also it assigns default value and ignores the properties value.
E.g. if I have defined the property like the one mentioned above and application properties file has something like this custom.data.export=true
then, the value of exportData
will still be false whereas it should be true ideally.
Can anyone please guide me what I am doing wrong here?
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…