Where to place a writable properties file in a java webapp?
I'm using a properties fi开发者_运维知识库le to store configuration information for a webapp. I'd like to allow the user to set certain values via the webapp. I'm just wondering where I should place it?
I see this is tagged with Spring
. Have you looked at the PropertyPlaceHolderConfigurer ?
This can be used to specify multiple property files used to expand properties in the Spring configs. You can use this to (say) specify a properties file on the classpath (in your app bundle) and an optional overriding properties file in (say) the user's home dir.
That way you can provide defaults in the app, and override using optional properties files in the user's home directory, the /etc/
filesystem etc. This is what I typically do, providing locations for different prperties files that are user-editable (in /home
) and admin editable (in /etc
).
I appreciate that this doesn't quite answer your question, but gives you new options for what you really want to achieve.
If it is project setting conf file, I would put it to ${user.home}/app/app-conf.properties
platform independent & uniform and easily accessible place
精彩评论