javax.persistence.PersistenceException: [PersistenceUnit: klmsdb] Unable to build EntityManagerFacto

javax.persistence.PersistenceException: [PersistenceUnit: klmsdb] Unable to build EntityManagerFactory
在Stack Overflow找到解决方法,他没错,只不过给了个成功的例子:Stack Overflow

原persistence.xml


<persistence 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    xmlns="http://java.sun.com/xml/ns/persistence"
    version="2.0">

    <persistence-unit name="klmsdb" transaction-type="RESOURCE_LOCAL">
        <properties>

            <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost/klmsdb;INIT=create schema IF NOT EXISTS sowa" />
            <property name="javax.persistence.jdbc.user" value="sa" />
            <property name="javax.persistence.jdbc.password" value="" />

            <property name="hibernate.hbm2ddl.auto" value="create" /> 
            <property name="hibernate.show_sql" value="true" />

        properties>

    persistence-unit>
persistence>

修改后的


<persistence 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    xmlns="http://java.sun.com/xml/ns/persistence"
    version="2.0">

    <persistence-unit name="klmsdb" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistenceprovider>
        <properties>


            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
            <property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/klmsdb;INIT=create schema IF NOT EXISTS sowa" />
            <property name="hibernate.connection.driver_class" value="org.h2.Driver" />
            <property name="hibernate.connection.username" value="sa" />
            <property name="hibernate.connection.password" value="" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="false" />

        properties>

    persistence-unit>
persistence>

你可能感兴趣的:(Java)