【发布时间】:2011-09-07 09:30:46
【问题描述】:
有没有办法在 Spring 中获取所有 @Entity 类? 我似乎找不到任何解决方案。 谢谢。
答案:
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.5</version>
</dependency>
很容易做到这一点;)
【问题讨论】:
有没有办法在 Spring 中获取所有 @Entity 类? 我似乎找不到任何解决方案。 谢谢。
答案:
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.5</version>
</dependency>
很容易做到这一点;)
【问题讨论】:
为什么需要这个?我想你在 JPA 上下文中,那么你可以这样做:
entityManager.getMetamodel().getEntities();
【讨论】: