【发布时间】:2012-11-11 13:10:39
【问题描述】:
我正在关注 OpenJPA 上的本教程 -> http://plunchete.wordpress.com/2007/05/06/using-openjpa/
我收到此错误:
160 INFO [main] openjpa.Runtime - OpenJPA dynamically loaded the class enhancer. Any classes that were not enhanced at build time will be enhanced when they are loaded by the JVM.
188 INFO [main] openjpa.Runtime - Starting OpenJPA 2.2.1
Exception in thread "main" <openjpa-2.2.1-r422266:1396819 fatal user error
org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class
name must be specified in the ConnectionDriverName property. Available properties in
configuration are "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
at
org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)
Persistence.xml 是这样的:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
<persistence-unit name="example" transaction-type="RESOURCE_LOCAL">
<provider>
org.apache.openjpa.persistence.PersistenceProviderImpl
</provider>
<class>Person</class>
<properties>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" />
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/cs5200" /
<property name="openjpa.ConnectionUserName" value="root" />
<property name="openjpa.ConnectionPassword" value="" />
</properties>
</persistence-unit>
</persistence>
【问题讨论】:
-
有人对此有任何想法吗?
-
你能和我们分享你的persistence.xml吗?
-
我现在在中国写信,没有wordpress :)
-
@jedrus07 我已经添加了
-
看起来您可能没有所需的 com.mysql.jdbc.Driver。您是否将其包含在您的 POM 文件中(鉴于这是一个 Maven 项目)?所需的条目是:
mysql mysql-connector-java 5.1.6
标签: java hibernate jpa persistence openjpa