简体   繁体   English

属性位置

[英]Properties location

I need to create a properties file to store username/passwords for DBs and other websites for my application. 我需要创建一个属性文件来存储我的应用程序的DB和其他网站的用户名/密码。

Is there a good place to put this? 有这个好地方吗?

I was thinking of putting in /usr/local/myapp/myapp.properties 我想放入/usr/local/myapp/myapp.properties

However...this doesnt really make much sense for Windows boxes. 但是......对于Windows机箱来说,这并没有多大意义。 However, I don't want to store it under a particular user's account as I want it to be global for all users. 但是,我不希望将其存储在特定用户的帐户下,因为我希望它对所有用户都是全局的。

Any thoughts? 有什么想法吗?

Store it wherever you like, and point your application to it via a vm parameter: -Dproperties.location=/usr/local/... 将它存储在任何您喜欢的位置,并通过vm参数指向您的应用程序: -Dproperties.location=/usr/local/...

Then you can read it with System.getProperty("properties.location") 然后你可以用System.getProperty("properties.location")读取它

I have written on this property framework for the last year. 我已经写了去年的这个房产框架。 It will provide of multiple ways to load properties, and have them strongly typed as well. 它将提供多种加载属性的方法,并且也可以强类型化。 Which also include a way to encrypt/decrypt a password property. 其中还包括加密/解密密码属性的方法。

Have a look at http://sourceforge.net/projects/jhpropertiestyp/ 看看http://sourceforge.net/projects/jhpropertiestyp/

JHPropertiesTyped will give the developer strongly typed properties. JHPropertiesTyped将为开发人员提供强类型属性。 Easy to integrate in existing projects. 易于集成到现有项目中。 Handled by a large series for property types. 由一系列属性类型处理。 Gives the ability to one-line initialize properties via property IO implementations. 通过属性IO实现提供单行初始化属性的功能。 Gives the developer the ability to create own property types and property io's. 使开发人员能够创建自己的属性类型和属性io。 Web demo is also available, screenshots shown above. 网络演示也可用,截图如上所示。 Also have a standard implementation for a web front end to manage properties, if you choose to use it. 如果您选择使用它,还可以使用Web前端的标准实现来管理属性。

Complete documentation, tutorial, javadoc, faq etc is a available on the project webpage. 项目网页上提供了完整的文档,教程,javadoc,faq等。

If you use the built-in Preferences class, the values will be automatically saved in the appropriate place on the user's system. 如果使用内置的Preferences类,则值将自动保存在用户系统的适当位置。

Edit: 编辑:

Oops, I missed the "global to all users" requirement. 哎呀,我错过了“全球所有用户”的要求。 This will not work on all systems in that case. 在这种情况下,这不适用于所有系统。

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

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