properties配置文件没有加载成功
1.需要将properties配置文件放在src目录下。
2.加载配置文件的时候,直接写文件名称,不需要写绝对路径和相对路径。
public static void init(){
Properties properties = new Properties();
InputStream is = BaseDao.class.getClassLoader().getResourceAsStream("datasource.properties");
try {
properties.load(is);
} catch (IOException e) {
e.printStackTrace();
}
driver = properties.getProperty("driver");
url = properties.getProperty("url");
username = properties.getProperty("username");
password = properties.getProperty("password");
}