System.getProperty("key")从何处读取(哪个属性文件)? [英] Where (which properties file) does System.getProperty("key") reads from?

查看:4709
本文介绍了System.getProperty("key")从何处读取(哪个属性文件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用String str = System.getProperty("key","default");,它总是返回默认值,因为我无法在属性文件中设置键值对.

My application uses String str = System.getProperty("key","default"); which always returns default because i am not able to set the key-value pair in the properties file.

我尝试在用户-> appdata-> locallow-> sun-> java> deployment中的deployment.properties文件中进行设置,并且还直接将key = value放入Java控制面板中的运行时参数中,但是不起作用.

I tried setting it in deployment.properties file located in users->appdata->locallow->sun->java>deployment and also directly putting key=value in runtime parameter in java control panel but not working.

请帮助我正确设置它,或者如果存在要设置这些值的其他属性文件,请共享路径? 我用Google搜索,但找不到.谢谢

Please help me to set it correctly or if there exist a different properties file where these values is to be set, kindly share the path ? I google it but couldn't find.Thanks in Advance

我们使用jeety服务器进行部署.我们还有许多与源代码捆绑在一起的属性文件.

We use jeety server for deployment.And we have many properties file bundled with our souce code.

推荐答案

如果要为System.getProperty设置自定义属性文件,这就是我们在这里要做的事情:

If you want to setup a custom property file for System.getProperty, this is what we here do:

  1. 为您将为Web应用程序创建的所有类创建一个基类作为基对象.
  2. 在基类中,编写此代码
  1. Create a base class as a base object for all the class you'll make for your web application.
  2. In base class, write this code
java.io.InputStream is = loader.getResourceAsStream("custom system property filename");
System.getProperties().load(is);

这篇关于System.getProperty("key")从何处读取(哪个属性文件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆