我想将 Spring Data JPA 与 Hibernate 映射文件一起使用并且不使用 JPA-Annotations。
但是我在服务器启动(tomcat)时遇到了这个异常:
java.lang.IllegalStateException: No persistence units parsed from {classpath*:META-INF/persistence.xml}
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.obtainDefaultPersistenceUnitInfo(DefaultPersistenceUnitManager.java:547)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.determinePersistenceUnitInfo(LocalContainerEntityManagerFactoryBean.java:311)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:260)
My dispatch-servlet.xml looks like the following:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<!--<property name="persistenceUnitName" value="BLUPP" />-->
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter" />
<!-- <property name="packagesToScan" value="org.cleanyourway.server.beans" />-->
<property name="persistenceUnitPostProcessors">
<list>
<bean
class="org.springframework.data.jpa.support.ClasspathScanningPersistenceUnitPostProcessor">
<constructor-arg value="org.xxxxxx.server.beans" />
<property name="mappingFileNamePattern" value="**hbm.xml" />
</bean>
</list>
</property>
</bean>
是否可以将 Hibernate 映射文件与 ClasspathScanningPersistenceUnitPostProcessor 一起使用?
我让它运行
<property name="packagesToScan" value="org.xxxxxxx.server.beans" />
和 JPA 注释。
谢谢你的帮助!