您还可以利用Spring的
DataSourceInitializer。以下是针对它的Java Config的示例。
@Beanpublic DataSourceInitializer dataSourceInitializer() { ResourceDatabasePopulator resourceDatabasePopulator = new ResourceDatabasePopulator(); resourceDatabasePopulator.addscript(new ClassPathResource("/data.sql")); DataSourceInitializer dataSourceInitializer = new DataSourceInitializer(); dataSourceInitializer.setDataSource(dataSource()); dataSourceInitializer.setDatabasePopulator(resourceDatabasePopulator); return dataSourceInitializer; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)