首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

读取properties文件有关问题

2012-01-20 
读取properties文件问题我的代码如下:PropertiespropnewProperties()InputStreamisgetClass().getResou

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

热点排行