0

尝试启动休眠时出现此错误。我是一个冬眠新手,所以希望有人能指出我在 cfg 上犯的错误。我包括了错误,希望它是一个简单的修复,谢谢。

<?xml version='1.0' encoding='utf-8'?>

    <!-- Database connection settings -->
    <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl"</property>
    <property name="connection.username">scott</property>
    <property name="connection.password">tiger</property>
    <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">true</property>
</session-factory>

Exception in thread "main" org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2241)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:230)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:71)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2158)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:212)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:71)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2137)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:206)
at HibernateContext.setConfiguration(HibernateContext.java:20)
at HibernateContext.addClass(HibernateContext.java:205)
at HibernateContext.addClasses(HibernateContext.java:216)
at main.main(main.java:8)

引起:org.xml.sax.SAXParseException;行号:14;列号:89;必须为元素类型“property”声明属性“value”。com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source) at com.sun.org .apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal .impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source) at com.sun.org.apache.xerces.internal.impl.dtd .XMLDTDValidator.handleStartElement(Unknown Source) 在 com。

4

2 回答 2

0

改变 :connection.driver_class

官方: hibernate.connection.driver_class

还阅读了这篇文章

于 2013-02-11T19:13:26.007 回答
0

尝试使用 <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>

作为新手,您可以在 http://www.hibernate.org/docs上阅读整个 hibernate 文档

于 2013-02-11T19:14:28.990 回答