Bee从V1.11开始,配置文件支持多环境差异化配置。
#since V1.11
#1.base main and Override with active, 2.rebase to active(other file)
#1 : main file + other file; 2 : just active file(other file); if do not set , will use mail file.
#bee.profiles.type=0
#命名规则 name rule: bee-{active}.properties
#bee.profiles.active = test
1、 比如所有的配置,开发环境,生产环境,除了数据库连接信息,其它的都相同。
在bee.properties中,配置:
bee.profiles.type=1
#命名规则 name rule: bee-{active}.properties
bee.profiles.active = prod
以上配置,表示以bee.properties为主,不一样的信息可以放在 bee-prod.properties中。
2、在bee.properties中,配置:
bee.profiles.type=2
#命名规则 name rule: bee-{active}.properties
bee.profiles.active = test
则表示,会使用bee-test.properties的配置信息,而bee.properties则不再使用。
另外,Bee支持设置bee.properties所在的文件夹位置。
实例中bee.properties放在:D:\temp中。
HoneyConfig.getHoneyConfig().resetBeeProperties("D:\\temp\\");
suid.select(new TestUser()); // 对DB操作的示例
/**
* 使用指定路径的bee.properties进行配置.set the folder path of bee.properties
* 若使用第三方框架管理配置,不建议在此处重置配置.
* @param folderPath bee.properties所在的路径. the folder path of bee.properties
* @since 1.9.8
*/
public void resetBeeProperties(String folderPath) {
。。。
}