本文整理汇总了Java中org.apache.ibatis.io.Resources.getResourceAsProperties方法的典型用法代码示例。如果您正苦于以下问题:Java Resources.getResourceAsProperties方法的具体用法?Java Resources.getResourceAsProperties怎么用?Java Resources.getResourceAsProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ibatis.io.Resources
的用法示例。
在下文中一共展示了Resources.getResourceAsProperties方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldRunScriptsUsingProperties
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
@Test
public void shouldRunScriptsUsingProperties() throws Exception {
Properties props = Resources.getResourceAsProperties(JPETSTORE_PROPERTIES);
DataSource dataSource = new UnpooledDataSource(
props.getProperty("driver"),
props.getProperty("url"),
props.getProperty("username"),
props.getProperty("password"));
ScriptRunner runner = new ScriptRunner(dataSource.getConnection());
runner.setAutoCommit(true);
runner.setStopOnError(false);
runner.setErrorLogWriter(null);
runner.setLogWriter(null);
runJPetStoreScripts(runner);
assertProductsTableExistsAndLoaded();
}
示例2: createUnpooledDataSource
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
public static UnpooledDataSource createUnpooledDataSource(String resource) throws IOException {
Properties props = Resources.getResourceAsProperties(resource);
UnpooledDataSource ds = new UnpooledDataSource();
ds.setDriver(props.getProperty("driver"));
ds.setUrl(props.getProperty("url"));
ds.setUsername(props.getProperty("username"));
ds.setPassword(props.getProperty("password"));
return ds;
}
示例3: create
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
/**
* Factory method to create session factory based on config,
* environment from config and properties file to populate parameters in config ${param}
*/
public SqlSessionFactory create() throws IOException {
InputStream inputStream = null;
Properties properties = null;
inputStream = Resources.getResourceAsStream(configFile);
properties = Resources.getResourceAsProperties("mybatis/config/mybatis.properties");
return sqlSessionFactoryBuilder.build(inputStream, environment, properties);
}
示例4: createUnpooledDataSource
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
public static UnpooledDataSource createUnpooledDataSource(String resource) throws IOException {
Properties props = Resources.getResourceAsProperties(resource);
UnpooledDataSource ds = new UnpooledDataSource();
ds.setDriver(props.getProperty("driver"));
ds.setUrl(props.getProperty("url"));
ds.setUsername(props.getProperty("username"));
ds.setPassword(props.getProperty("password"));
return ds;
}
示例5: createPooledDataSource
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
public static PooledDataSource createPooledDataSource(String resource) throws IOException {
Properties props = Resources.getResourceAsProperties(resource);
PooledDataSource ds = new PooledDataSource();
ds.setDriver(props.getProperty("driver"));
ds.setUrl(props.getProperty("url"));
ds.setUsername(props.getProperty("username"));
ds.setPassword(props.getProperty("password"));
return ds;
}
示例6: createUnpooledDataSource
import org.apache.ibatis.io.Resources; //导入方法依赖的package包/类
public static UnpooledDataSource createUnpooledDataSource(String resource,
String dbName)
throws IOException {
Properties props = Resources.getResourceAsProperties(resource);
UnpooledDataSource ds = new UnpooledDataSource();
ds.setDriver(props.getProperty(dbName + ".driver"));
ds.setUrl(props.getProperty(dbName + ".url"));
ds.setUsername(props.getProperty(dbName + ".username"));
ds.setPassword(props.getProperty(dbName + ".password"));
return ds;
}