我的笔记
程序中为了连接数据库,存在很多数据库的集群的信息,为了能让程序在不同的的集群中运行,需要到程序中更改集群数据库的配置。这里希望
能将这些配置单独写成一个配置文件,方便迁移。
在Windows系统下将配置信息直接写到resource目录下的配置文件(.properties文件)里即可,读取该conf.properties文件代码如下:
val properties = new Properties()
val path = Thread.currentThread().getContextClassLoader.getResource("conf.properties").getPath
properties.load(new FileInputStream(path))
val hbase_quorum = properties.getProperty("hbase_quorum")
//"hbase_quorum"为conf.properties文件中键值名