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

来源:互联网 发布:linux虚拟网桥 编辑:程序博客网 时间:2024/06/05 00:14

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

原persistence.xml

<?xml version="1.0" encoding="UTF-8" ?><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>

修改后的

<?xml version="1.0" encoding="UTF-8" ?><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.HibernatePersistence</provider>        <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>
阅读全文
1 0