日期:2014-05-20  浏览次数:20847 次

读取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的配置文件或它的路径对吗