我想配置我的 EntityManagerFactoryBean 属性“ packagesToScan ”以使用正则表达式(如弹簧上下文组件扫描通常会这样做)。但是我能得到的最类似的行为是使用一系列包。
有这样的版本可供使用吗?
com.myproject.*.entity
这是我的 EntityManagerFactoryBean config:
<beans:bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="packagesToScan">
<beans:array>
<beans:value>com.myproject.web.users.entity</beans:value>
</beans:array>
</beans:property>
<beans:property name="jpaVendorAdapter">
<beans:bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</beans:property>
<beans:property name="jpaProperties">
<beans:props>
<beans:prop key="hibernate.hbm2ddl.auto">update</beans:prop><!-- https://stackoverflow.com/questions/438146/hibernate-hbm2ddl-auto-possible-values-and-what-they-do -->
<beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</beans:prop>
</beans:props>
</beans:property>
</beans:bean>