1. 程式人生 > >寫hibernate.cfg.xml時報錯The content of element type "property" must match "(meta*,(column|formula)*,type?)".

寫hibernate.cfg.xml時報錯The content of element type "property" must match "(meta*,(column|formula)*,type?)".

原配置檔案是這樣的

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-configuration>
    <session-factory>
        <!-- 第一部分:配置資料庫資訊 -->
        <
property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver </property> </session-factory> </hibernate-configuration>

改成下面這樣就可以了。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"
> <hibernate-configuration> <session-factory> <!-- 第一部分:配置資料庫資訊 --> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> </session-factory> </hibernate-configuration>