gpt4 book ai didi

java - 未找到 Hibernate 逆向工程持久性单元

转载 作者:行者123 更新时间:2023-12-02 08:24:49 26 4
gpt4 key购买 nike

我在 Eclipse IDE 中有一个 java maven3 项目,安装了 jboss 工具。我正在使用 hibenrate4

我正在尝试在 hibernate View 中设置 hibenrate 配置来测试 hql 查询,问题是它找不到持久性单元。我将 persistence.xml 放置在 src/main/resources/META-INF/persistence.xml

是否有一些我需要设置的 Maven 配置?

project structure

hibenrate configuration

hibernate configuration

persistence unit not found error

持久性.xml

   <persistence-unit  name="ypay">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/ypay</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<!-- <property name="hibernate.hbm2ddl.auto" value="validate" /> -->
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
</properties>

hibernate 属性

hibernate.connection.password=
hibernate.connection.username=root
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
hibernate.connection.url=jdbc:mysql://****************:3306/ypay?useUnicode=true&amp;characterEncoding=UTF-8
hibernate.connection.provider_class=org.hibernate.connection.DriverManagerConnectionProvider
hibernate.datasource=
hibernate.transaction.manager_lookup_class=

最佳答案

您需要一个 META-INF/persistence.xml 以及

<persistence-unit name="ypay">

(一般放在WEB-INF/classes/META-INF,使用maven时可以尝试放在src/main/resources/META-INF)

请引用this文档了解详细信息。

关于java - 未找到 Hibernate 逆向工程持久性单元,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24322965/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com