我已阅读有关EclipseLink架构数据初始化的this question,我想在Spring Data JPA中实现相同的目标。
答案都假定存在persistence.xml
文件,我没有使用。
相反,我有Spring配置,如下所示:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
<property name="packagesToScan" value="rbf.staffing.data"/>
<property name="jpaPropertyMap">
<map>
<entry key="eclipselink.weaving" value="false"/>
<entry key="eclipselink.id-validation" value="NULL"/>
<entry key="eclipselink.ddl-generation" value="create-tables" />
<entry key="javax.persistence.sql-load-script-source" value="main/resources/import.sql" />
</map>
</property>
</bean>
jpaVendorAdapter
是EclipseLinkJpaVendorAdapter
。
所有DDL都很好用,但import.sql
没有被执行。它位于src/main/resources