Avatar of Rohit Bajaj
Rohit Bajaj
Flag for India asked on

using properties file in spring java mvc along with xml files

HI,
I have a spring java project i found that its using two files :
1) database.xml
2) database.properties

The database.properties file specify the jdbc url and username and password
These properties are then used in database.xml file with the notation "${}" to access the jdbc url and username and password

My question is why create the database.properties file in the first place ? arent xml files also non compiled and so one can directly edit them without restarting the server ?
Is it just for a readability purpose or there are some other significance of using this pattern ?
JavaXML

Avatar of undefined
Last Comment
mccarl

8/22/2022 - Mon
SOLUTION
srikotesh

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Rohit Bajaj

ASKER
what is the exact reason.
1) why server restart is not required when changing properties file?
2) why it is required when xml is changed ?
i have read somewhere that there are hot deployment ways. like using jrebel etc which automatically handles any change....i think using that does not require server restart
srikotesh

properties file no need to compile
where as xml we need to recompile and restart the server.
ASKER CERTIFIED SOLUTION
mccarl

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mccarl

As to what support the application has for HOT changes to those setting, it is still a case-by-case basis. As you have it now, where those properties are used by the XML with ${} placeholders, without further external support you STILL need to restart the server for any changes to those DB parameters.

However, there are other cases where you CAN easily support HOT changes to .properties file without needing server restarts, and you could do this easier than having the changes applied to the .xml file.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck