properties不单是配置文件,而是一个集合类型
读取配置文件时就使用这个集合,将配置信息以键值对的形式读取进来。
例如:JDBC 数据库连接池读取配置时 需要先建一个properties集合然后用这个properties读取信息。
举例: Ddruid的引入properties配置文件
@Test
public void testResourcesDruid() throws Exception {
//1.创建Properties集合,用于存储外部配置文件的key和value值。
Properties properties = new Properties();
//2.读取外部配置文件,获取输入流,加载到Properties集合里。
InputStream inputStream = DruidTest.class.getClassLoader().getResourceAsStream("db.properties");
properties.load(inputStream);
//3.基于Properties集合构建DruidDataSource连接池
DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
//4.通过连接池获取连接对象
Connection connection = dataSource.getConnection();
System.out.println(connection);
//5.开发CRUD
//6.回收连接
connection.close();
}
推荐阅读:
vue.js:634 [Vue warn]: Property or method "userName" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See:
状态码:415,发送HTTP请求返回415状态码的解决办法
SpringBoot 整合 webapp时 访问404的解决办法
Vue 打开页面时就加载方法,例如查询
SpringCloud怎么调用多个服务的信息
Spring整合Mybatis
SpringCloud 加入 thymleaf前端页面的方法
Controller之间的跳转
Spring AOP的实现原理
This may be the result of an unspecified view, due to default view name generation
行动消除疑虑