我是否需要persistence.xml中的<class>元素?
我有一个非常简单的persistance.xml文件: <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="eventractor" transaction-type="RESOURCE_LOCAL"> <class>pl.michalmech.eventractor.domain.User</class> <class>pl.michalmech.eventractor.domain.Address</class> <class>pl.michalmech.eventractor.domain.City</class> <class>pl.michalmech.eventractor.domain.Country</class> <properties> <property name="hibernate.hbm2ddl.auto" value="validate" /> <property name="hibernate.show_sql" value="true" /> </properties> </persistence-unit> </persistence> 而且有效。 但是,当我删除<class>元素时,应用程序看不到实体(所有类都带有注释@Entity)。 是否有自动扫描@Entity类的机制?