用于管理 glassfish/tomcat/etc 中的 .properties 文件的优雅解决方案
有人有一个好的解决方案来管理 Web 应用程序中的 .properties 文件吗?目前,我必须在部署之前拆开 .war 文件,更改 .properties 文件中的条目,然后重新部署以更改设置。
或者,我可以通过 ssh 进入服务器,更改部署目录中的 .properties 文件并重新启动应用程序。
同事有一个相当优雅的解决方案,使用 GUI 在 Tomcat/Glassfish 实例中设置 JNDI 属性并读取这些属性而不是 .properties 文件。这里的问题是,当将应用程序交给我们的运营团队时,他们需要知道要添加到 JNDI 的属性。
有没有人找到解决这个问题的好方法?
Does anybody have a good solution for managing .properties files in a web application? Currently I have to pull apart my .war file before deploying, change the entries in my .properties file, and then redeploy to change settings.
Alternatively I can ssh into the server, change the .properties file in the deploy directory and restart the application.
A coworker has a rather elegant solution of using the GUI for setting JNDI properties in your Tomcat/Glassfish instance and reading those instead of a .properties file. The problem here is that when handing off the application to our operations teams they need to know which properties to add to JNDI.
Has anybody found a great way to deal with this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个简单的选择是将属性文件存储在 WAR 文件/webapp 外部,这样 1) 它们在每次部署时都不会更改,2) 不需要进行编辑。您只需要调整您的网络应用程序中与文件所在位置相关的逻辑即可。
另一种选择稍微不太简单,是在构建过程中使用过滤,以便构建 WAR 文件以包含针对目标环境定制的属性文件。 Ant 和 Maven 支持一种非常简单的机制,使用令牌和过滤器文件来过滤某些资源。
One simple option is to store the properties file external to the WAR file / webapp, so that 1) they are not changed on each deployment and 2) do not need to be edited. You would simply need to adjust the logic in your webapp having to do with where the files are found.
Another option, only slightly less simple, is to use filtering during the build process so that the WAR file is build to contain properties file that are customized to the target environment. Both Ant and Maven support a very easy mechanism for using tokens and filter files to filter certain resources.
如果你可以以xml格式存储属性(我相信jdk支持),那么有一堆开源库可以为此生成crud ui....如果不是我发现的最接近的是PropertySet @ 链接文本
if you can store the properties in xml format(which I believe jdk supports) then there are bunch of open source libs that can generate the crud ui for that....if not the closest i found is PropertySet @ link text