问题
I see a lot of how to read the file or locate it, but I've been trying to run Properties.store() and it simple does not modify the file.
I can read, get and set properties but store doesn't work. Should it work or is not meant to work?
If it doesn't work, how can I modify the file, so when the server restart those properties do not get lost?
回答1:
No; it's inside a WAR.
Technically you could un-zip it, modify it, zip it back up. But don't.
Properties like that should be stored in a DB, in JNDI, or in a file outside of the war.
回答2:
Property files bundled inside a JAR are not meant to change because they make part of the distribution.
回答3:
I wouldn't mess with unzipping/rezipping a WAR file, just as a piece of advice. I have done that in the past and it did not work so well.
来源:https://stackoverflow.com/questions/8408543/is-it-possible-to-write-on-a-properties-file-inside-a-war