Is it possible to write on a properties file inside a .war?

好久不见. 提交于 2019-12-12 05:47:19

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!