java - 无法将 openliberty、JPA 与 Hibernate 集成
问题描述
我正在尝试使用 JPA、Hibernate 和 OpenLiberty 来开发 JakartaEE 应用程序。
我遵循了这份文件:https ://openliberty.io/guides/jpa-intro.html#configuring-jpa
就我而言,我希望使用 jpaContainer-2.2 或 jpa-2.2。
部分代码片段如下,
持久性.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="jpaunit" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>jdbc/recruittimesdb</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="true" />
</properties>
</persistence-unit>
</persistence>
服务器.xml
<dataSource id="hibernatemysqldb"
jndiName="jdbc/recruittimesdb">
<jdbcDriver libraryRef="MySQLLib" />
<properties databaseName="recruit_times_db"
serverName="localhost" password="admin1234" user="root"
serverTimezone="UTC" portNumber="3306" />
</dataSource>
<library id="MySQLLib">
<file
name="C:/Users/harsha/Documents/mysql-connector-java-8.0.19.jar" />
</library>
<library id="hibernate">
<fileset dir="${config.dir}/hibernate/"
includes="*.jar" />
</library>
我仍然无法成功集成 Hibernate。很高兴看到一个有效的例子。
更新:
当服务器启动时,我收到此错误。
[INFO] [ERROR ] CWWJP0015E: An error occurred in the org.hibernate.jpa.HibernatePersistenceProvider persistence provider when it attempted to create the container entity manager factory for the jpaunit
持久性单元。发生以下错误:[PersistenceUnit: jpaunit] 无法构建 Hibernate SessionFactory
解决方案
推荐阅读
- python - 如何在套接字python中使用公共ip4
- c++ - 如何从许多函数中获取函数指针并将参数传递给它?
- c# - UI 在第一个字段后不响应接受任何输入
- jquery - 数据表 - 日期年龄 - 过滤器 ASC DESC
- flutter - Flutter - 上传 csv 文件
- firebase - Firebase 存储工件巨大且不断增加
- aws-lambda - 在 lambda 函数中存储和访问数据文件
- php - 在 Laravel 中从数据库中删除图像的问题
- reactjs - Redux 我应该如何处理 API 调用的更新
- c# - 如何通过两个属性 DC=intechww,DC=com 为 LDAP 创建连接字符串