读书人

读取properties文件有关问题

发布时间: 2012-01-20 18:53:53 作者: rapoo

读取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)

为什么提示读取不到文件啊?

[解决办法]
Do you want me move to the right forum?
[解决办法]
jf
[解决办法]
说一说怎么解决的。
[解决办法]
发布的时候文件没拷贝过去吧
[解决办法]
jf
[解决办法]
查找一下你tomcat下有没有hibernate的配置文件或它的路径对吗

读书人网 >J2SE开发

热点推荐