Я пытаюсь настроить hibernate с помощью mysql.
Ниже приводится hibernate.cfg.xml
:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/TestDB</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root123</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hdm2ddl.auto">create</property>property>
<property name="show_sql">false</property>
<!-- Use the C3P0 connection pool provider -->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<mapping resource="com/psl/course/Course.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Однако я получаю следующую ошибку.Трассировка стека следующая:
15 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
31 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
31 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
47 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
78 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
78 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
156 [main] ERROR org.hibernate.util.XMLHelper - Error parsing XML: /hibernate.cfg.xml(26) The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)".
Initial SessionFactory creation failed.org.hibernate.MappingException: invalid configuration
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.psl.util.HibernateUtil.(HibernateUtil.java:13)
at com.psl.course.Main.saveCourse(Main.java:34)
at com.psl.course.Main.main(Main.java:16)
Caused by: org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1521)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1448)
at com.psl.util.HibernateUtil.(HibernateUtil.java:10)
... 2 more
Caused by: org.xml.sax.SAXParseException: The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)".
at 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.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)
... 5 more
Помогите пожалуйста, где я не так?