我有一個maven項目,一個獨立的JPA工具。無法自動發現JPA2實體
該主項目依賴於另一個包含所有實體類的maven項目。
但是,JPA似乎沒有自動查找我的實體。我的Eclipse項目>屬性> jpa> auto discover,也被啓用。
我的persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" 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_1.xsd">
<persistence-unit name="myapp-ds" transaction-type="RESOURCE_LOCAL">
<description>Vecchio</description>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/myapp" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="xxx" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.archive.autodetection" value="class"/>
</properties>
</persistence-unit>
</persistence>
它位於目標/班/ META-INF。
錯誤,使用實體的時候是:
Exception in thread "main" java.lang.IllegalArgumentException: Unknown entity: model.legacy.dto.myentity
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1184)
at it.test.Main.main(Main.java:23)
我不想列出我所有的課程,他們是400+ – 2014-09-30 13:30:12