简体   繁体   English

从 .txt 读取值到 application.properties

[英]read value from .txt to application.properties

I created a maven project which connects to a database .我创建了一个连接到数据库的 Maven 项目。 The problem I am facing is I have hardcoded the db username and password but I according to the requirement it should be dynamically read from a .txt file in local path.我面临的问题是我对数据库用户名和密码进行了硬编码,但我根据要求应该从本地路径中的 .txt 文件中动态读取它。 Is there any possible way for this solution or any other strategy that I should follow.这个解决方案或我应该遵循的任何其他策略是否有任何可能的方法。

Thanks in advance提前致谢

java.util.Properties 类有几个易于使用的加载方法。

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

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