简体   繁体   English

在战争中修改属性文件

[英]Modifying a properties file inside a war

I understand that a properties file cannot be modified inside a war ( I cannot write to it) . 我知道在战争中无法修改属性文件(我无法对其进行写入)。 my war is essentially a java wrapper to make rest calls . 我的战争本质上是一个进行休息呼叫的java包装。 so essentially , I make a POST call to the app , the app does its magic makes a few calls to different services and returns the data to me in a particular format . 所以本质上,我对该应用程序进行了POST调用,该应用程序发挥了魔力,对不同的服务进行了几次调用,并以特定的格式将数据返回给我。 I am using apikey authentication to communicate with the application . 我正在使用apikey身份验证与应用程序通信。 I now want now design a private rest call to update some of these parameters incase we need to change the apikey at a later time . 现在,我现在想设计一个私有的rest调用来更新其中的一些参数,以防我们稍后需要更改apikey。

so essentially the app will read everything off an properties file . 因此从本质上讲,该应用程序将从属性文件中读取所有内容。 I now understand that I cannot write to a properties file when it is packaged in a war and am in quite a pickle . 我现在明白, 在战争中打包并腌制得很烂的时候 ,我无法写入属性文件 I cannot use a database because I am not sure which env it will be deployed to and I need it to be self contained . 我无法使用数据库,因为我不确定该数据库将部署到哪个环境中,并且我需要它是独立的。

Any help on how I can get over this problem will be greatly appreciated . 我如何克服这个问题的任何帮助将不胜感激。

You can use external property files as Sajan suggested. 您可以按照Sajan的建议使用外部属性文件。 Or use Java Preferences API 或使用Java Preferences API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM