读取properties文件问题
我的代码如下:
Properties prop = new Properties();
InputStream is=getClass().getResourceAsStream("/hibernate.properties");//hibernate.properties放就放在当前路径;
try{
prop.load(is);
}catch(Exception e){
e.printStackTrace();
}
hibernate.properties内容如下:
hibernate.dialect = org.hibernate.dialect.SQLServerDialect
hibernate.connection.driver_class = com.microsoft.jdbc.sqlserver.SQLServerDriver
hibernate.connection.url = jdbc:microsoft:sqlserver://localhost;databasename=hibernate
hibernate.connection.username = sa
hibernate.connection.password = sa
错误如下:java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load(Unknown Source)
为什么提示读取不到文件啊?