Hibernate错误:无法解析配置文件

时间:2014-09-25 20:25:32

标签: java database hibernate jpa configuration

您好我是java新手我试图在eclipse中执行hibernate这是我的配置文件 Hibernate.cfg.xml 我在记事本中编辑它并将其复制到我的应用程序

     
<!DOCTYPE hibernate-configuration PUBLIC  
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"  
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">  

<hibernate-configuration>  
    <session-factory>  
        <property name="hbm2ddl.auto">update</property>  
        <property name="dialect">org.hibernate.dialect.SqlServerDialect</property>  
        <property name="connection.url" value="jdbc:sqlserver://localhost;databaseName=empDb;instanceName=MSHassan"/>  
        <property name="connection.username">hmohamed</property>  
        <property name="connection.password">Kocroc1234</property>  
        <property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SqlServerDriver</property>  
    <mapping resource="employee.hbm.xml"/>  
    </session-factory>  
</hibernate-configuration>

我收到错误无法解析配置文件Hibernate.cfg.xml

1 个答案:

答案 0 :(得分:1)

您需要更改:

<property name="connection.url" value="jdbc:sqlserver://localhost;databaseName=empDb;instanceName=MSHassan"/>

为:

<property name="connection.url">jdbc:sqlserver://localhost;databaseName=empDb;instanceName=MSHassan</property>

前一种变体对JPA(在persistence.xml中)有效,而后者则是特定于Hibernate的cfg。