java.lang.Object
org.miaixz.bus.setting.magic.Profile
- All Implemented Interfaces:
Serializable
Profile可以让我们定义一系列的配置信息,然后指定其激活条件。 此类中我们规范一套规则如下:
默认的,我们读取${classpath}/default下的配置文件(*.setting文件),当调用setProfile方法时,指定一个profile,即可读取其目录下的配置文件。
比如我们定义几个profile:test,develop,production,分别代表测试环境、开发环境和线上环境,我希望读取数据库配置文件db.setting,那么:
- test = ${classpath}/test/db.setting
- develop = ${classpath}/develop/db.setting
- production = ${classpath}/production/db.setting
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclear()清空所有环境的配置文件getSetting(String name) 获取当前环境下的配置文件setCharset(Charset charset) 设置编码setProfile(String profile) 设置环境setUseVar(boolean useVar) 设置是否使用变量
-
Constructor Details
-
Profile
public Profile()默认构造,环境使用默认的:default,编码UTF-8,不使用变量 -
Profile
构造,编码UTF-8,不使用变量- Parameters:
profile- 环境
-
Profile
构造- Parameters:
profile- 环境charset- 编码useVar- 是否使用变量
-
-
Method Details
-
getSetting
获取当前环境下的配置文件- Parameters:
name- 文件名,如果没有扩展名,默认为.setting- Returns:
- 当前环境下配置文件
-
setProfile
设置环境- Parameters:
profile- 环境- Returns:
- 自身
-
setCharset
设置编码- Parameters:
charset- 编码- Returns:
- 自身
-
setUseVar
设置是否使用变量- Parameters:
useVar- 变量- Returns:
- 自身
-
clear
清空所有环境的配置文件- Returns:
- 自身
-