Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么没有隐式地发现我的JPA注释类?_Java_Hibernate_Jpa - Fatal编程技术网

Java 为什么没有隐式地发现我的JPA注释类?

Java 为什么没有隐式地发现我的JPA注释类?,java,hibernate,jpa,Java,Hibernate,Jpa,我的persistence.xml看起来像: <persistence> <persistence-unit name="test"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <class>com.XXX.Abc</class> <properties> <property name="h

我的
persistence.xml
看起来像:

<persistence>
  <persistence-unit name="test">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>com.XXX.Abc</class>
    <properties>
      <property name="hibernate.archive.autodetection" value="true" />
      ..
    </properties>
  </persistence-unit>
<persistence>

虽然我使用的是
@Entity
,但hibernate似乎无法发现带注释的类。。为什么?

试着把它做成……像这样

<property name="hibernate.archive.autodetection" value="class" />   


hibernate.archive.autodetection的值是由hibernate自动发现的元素的csv列表

请尝试以下方法:

<property name="hibernate.archive.autodetection" value="class, hbm"/>


进一步阅读

  • (有一个包含属性文档的表)

我认为Hibernate查找与persistence.xml相同的代码源中的类。例如,如果您将persistence.xml放在一个文件夹中,将类放在一个单独的jar中,Hibernate将找不到它们。

对于他的情况,类就足够了。不需要hbm
<property name="hibernate.archive.autodetection" value="class, hbm"/>