Package | Description |
---|---|
org.dromara.hutool.setting |
Setting模块主要针对Properties文件读写做封装,同时定义一套自己的配置文件规范,实现兼容性良好的配置工具。
|
org.dromara.hutool.setting.props |
配置文件实现封装,例如Properties封装Props
|
Modifier and Type | Method and Description |
---|---|
Props |
Setting.getProps(String group)
获取group分组下所有配置键值对,组成新的
Props |
Props |
Setting.toProps()
转换为
Props 对象,原分组变为前缀 |
Modifier and Type | Method and Description |
---|---|
static Props |
PropsUtil.get(String name)
获取当前环境下的配置文件
name可以为不包括扩展名的文件名(默认.properties),也可以是文件名全称 |
static Props |
PropsUtil.getFirstFound(String... names)
获取给定路径找到的第一个配置文件
* name可以为不包括扩展名的文件名(默认.properties为结尾),也可以是文件名全称 |
Props |
Props.getSubProps(String prefix)
获取一个新的子属性,子属性键值对拥有公共前缀,以.分隔。
|
static Props |
PropsUtil.getSystemProps()
获取系统参数,例如用户在执行java命令时定义的 -Duse=hutool
|
static Props |
Props.of()
构建一个空的Props,用于手动加入参数
|
static Props |
Props.of(Properties properties)
Properties 转为Props |
static Props |
Props.of(String resource)
获得Classpath下的Properties文件
|
static Props |
Props.of(String resource,
Charset charset)
获得Classpath下的Properties文件
|
Props |
Props.setFields(SerSupplier<?>... fields)
通过lambda批量设置值
实际使用时,可以使用getXXX的方法引用来完成键值对的赋值: User user = GenericBuilder.of(User::new).with(User::setUsername, "hutool").build(); Setting.of().setFields(user::getNickname, user::getUsername); |
Copyright © 2025. All rights reserved.