我在Eclipse IDE中安装了jboss工具的java maven3项目。我正在使用hibenrate4
我试图在hibernate视图中设置hibenrate configuratoin来测试hql查询,问题在于它无法找到持久性单元。我将persistence.xml放在src / main / resources / META-INF / persistence.xml
中是否有一些我必须设置的maven配置?
的persistence.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.properties
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&characterEncoding=UTF-8
hibernate.connection.provider_class=org.hibernate.connection.DriverManagerConnectionProvider
hibernate.datasource=
hibernate.transaction.manager_lookup_class=
答案 0 :(得分:0)
您需要META-INF/persistence.xml
<persistence-unit name="ypay">
(通常把它放在WEB-INF / classes / META-INF。使用maven时你可以尝试将它放在src / main / resources / META-INF中)
有关详细信息,请参阅this doc。