81,116
社区成员
发帖
与我相关
我的任务
分享Properties prop = new Properties();
try {
InputStream in = Object.class.getResourceAsStream("/resource.properties");
prop.load(in);
System.out.println(prop.getProperty("db.driver.class"));
System.out.println(prop.getProperty("db.url"));
System.out.println(prop.getProperty("db.username"));
} catch(IOException e) {
e.printStackTrace();
}
麻烦看下我的上条回帖
System.out.println(Constants.class.getClassLoader().getResource("struts.xml")); 或是 System.out.println(Constants.class.getClassLoader().getResource("mess.properties"));
都是可以输出路径的,唯独jdbc.properties输出是null, class文件夹下面是有jdbc.properties的,我也重新编译过了,十分之郁闷
