Java OpenJPA连接错误
我正在关注OpenJPA上的本教程-> 我得到这个错误:Java OpenJPA连接错误,java,hibernate,jpa,persistence,openjpa,Java,Hibernate,Jpa,Persistence,Openjpa,我正在关注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 - S
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)
160 INFO[main]openjpa.Runtime-openjpa动态加载类增强器。任何在构建时未增强的类在JVM加载时都将得到增强。
188信息[main]openjpa.Runtime-启动OpenJPA2.2.1
线程“main”中出现异常错误是文件夹结构错误
META-INF应该在src文件夹中
不是这样的。我研究和测试了不同的东西,提出了这个解决方案
我希望它能对将来的人有所帮助。有人对此有任何想法吗?你能与我们分享你的persistence.xml吗?我目前在中国写作,没有wordpress:)@jedrus07我现在已经添加了它。看起来你可能没有所需的-com.mysql.jdbc.Driver。您是否将其包含在POM文件中(假设这是一个maven项目)?必需的条目是:mysql连接器java 5.1.6我正要对此发表评论。很高兴您找到了解决方案!-别忘了接受你自己的答案!
<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>