1

我正在关注 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>
4

1 回答 1

2

错误是文件夹结构错误。

META-INF 应该在 src 文件夹中。

不是那样的。我研究并测试了不同的东西并提出了这个解决方案。

我希望将来对某人有所帮助。

于 2012-11-23T08:17:21.967 回答