我希望如果数据库中不存在表,那么它们应该自动创建,但它们不应该覆盖现有数据或删除表。
我在属性文件
中使用过spring.jpa.properties.hibernate.hbm2ddl.auto=update
我试过了#34;没有"选项也是。
我的 entityManager
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
factoryBean.setDataSource(dataSource());
factoryBean.setJpaVendorAdapter(jpaVendorAdapter);
factoryBean.setPackagesToScan(R.Blueberry_PACKAGE);
factoryBean.setPersistenceUnitName("blueberryPersistenceUnit");
Properties jpaProperties = new Properties();
factoryBean.setJpaProperties(jpaProperties);
factoryBean.afterPropertiesSet();
return factoryBean.getObject();
jpaVendor
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
jpaVendorAdapter.setShowSql(true);
jpaVendorAdapter.setGenerateDdl(true);
jpaVendorAdapter.setDatabase(Database.MYSQL);
return jpaVendorAdapter;
}