use of cn.hutool.setting.dialect.Props in project hutool by looly.
the class PropsTest method propTest.
@Test
public void propTest() {
Props props = new Props("test.properties");
String user = props.getProperty("user");
Assert.assertEquals(user, "root");
String driver = props.getStr("driver");
Assert.assertEquals(driver, "com.mysql.jdbc.Driver");
}
use of cn.hutool.setting.dialect.Props in project hutool by looly.
the class PropsTest method propTestForAbsPAth.
@Test
@Ignore
public void propTestForAbsPAth() {
Props props = new Props("d:/test.properties");
String user = props.getProperty("user");
Assert.assertEquals(user, "root");
String driver = props.getStr("driver");
Assert.assertEquals(driver, "com.mysql.jdbc.Driver");
}
use of cn.hutool.setting.dialect.Props in project hutool by looly.
the class Setting method getProps.
/**
* 获取group分组下所有配置键值对,组成新的{@link Props}
*
* @param group 分组
* @return Props对象
* @since 4.1.21
*/
public Props getProps(String group) {
final Props props = new Props();
props.putAll(getMap(group));
return props;
}
use of cn.hutool.setting.dialect.Props in project hutool by looly.
the class PropsTest method toBeanWithNullPrefixTest.
@Test
public void toBeanWithNullPrefixTest() {
Props configProp = new Props();
configProp.setProperty("createTime", Objects.requireNonNull(DateUtil.parse("2020-01-01")));
configProp.setProperty("isInit", true);
configProp.setProperty("stairPlan", 1);
configProp.setProperty("stageNum", 2);
configProp.setProperty("version", 3);
SystemConfig systemConfig = configProp.toBean(SystemConfig.class);
Assert.assertEquals(DateUtil.parse("2020-01-01"), systemConfig.getCreateTime());
Assert.assertEquals(true, systemConfig.getIsInit());
Assert.assertEquals("1", systemConfig.getStairPlan());
Assert.assertEquals(new Integer(2), systemConfig.getStageNum());
Assert.assertEquals("3", systemConfig.getVersion());
}
use of cn.hutool.setting.dialect.Props in project hutool by looly.
the class C3p0DSFactory method createDataSource.
@Override
protected DataSource createDataSource(String jdbcUrl, String driver, String user, String pass, Setting poolSetting) {
final ComboPooledDataSource ds = new ComboPooledDataSource();
// remarks等特殊配置,since 5.3.8
final Props connProps = new Props();
String connValue;
for (String key : KEY_CONN_PROPS) {
connValue = poolSetting.getAndRemoveStr(key);
if (StrUtil.isNotBlank(connValue)) {
connProps.setProperty(key, connValue);
}
}
if (MapUtil.isNotEmpty(connProps)) {
ds.setProperties(connProps);
}
ds.setJdbcUrl(jdbcUrl);
try {
ds.setDriverClass(driver);
} catch (PropertyVetoException e) {
throw new DbRuntimeException(e);
}
ds.setUser(user);
ds.setPassword(pass);
// 注入属性
poolSetting.toBean(ds);
return ds;
}
Aggregations