通过properties配置文件获取环境变量


在shell脚本中导入环境变量,如export UNSENT_MESSAGES=/log/unsent_messages.txt

在config.properties中,unsentFile=UNSENT_MESSAGES

在java文件中获取变量

property.load(new FileInputStream("config.properties"));
String unsentMessageFile = property.getProperty("unsentFile");
String filePath = System.getenv(unsentMessageFile);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM