Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Priority of Various Sources in PropertySources

Spring has introduced a new annotation @PropertySources for all classes marked as @Configuration since 4.0. It takes different @PropertySource as argument.

@PropertySources({
    @PropertySource("classpath:application.properties"), @PropertySource("file:/tmp/application.properties")})

What I am interested is knowing is the ordering in case of conflict in values for the same key present in multiple properties file. I have not seen any documentation related to this that specifies an ordering. I have tries it multiple times and found that the PropertySource mentioned later is overwriting the value present in PropertySource mentioned before. But, how to be sure?

like image 778
azi Avatar asked Aug 27 '15 13:08

azi


1 Answers

HL'REB is right. "Win" the parameter from the last properties file. However, application.properties overrides all values. Checked for SPRING 5.1.6.

like image 103
bairamovazat Avatar answered Nov 01 '22 21:11

bairamovazat