我从来没有得到那个工作。如果你只是想要开发数据的快照(在启动时加载),我发现使用DBUnit导出/导入数据对我来说非常合适。我写了一个脚本来导出,我从控制台呼叫:
class DataExport {
def ctx = SCH.servletContext.getAttribute(GA.APPLICATION_CONTEXT)
def exportData() {
println "-->export"
def ds = ctx.dataSourceUnproxied
println ds.dump()
Connection jdbcConnection = ctx.dataSourceUnproxied.getConnection()
IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
println connection.dump()
ITableFilter filter = new DatabaseSequenceFilter(connection);
IDataSet dataset = new FilteredDataSet(filter, connection.createDataSet());
FlatXmlDataSet.write(dataset, new File("full.xml").newWriter());
connection.close()
}
}
然后在引导你可以加载它放回
Connection jdbcConnection
FlatXmlDataSet dataSet = new FlatXmlDataSetBuilder().build(new ClassPathResource('resources/data/full.xml').inputStream)
jdbcConnection = ctx.dataSource.getConnection()
IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
try {
DatabaseOperation.INSERT.execute(connection, dataSet)
} catch(e) {
e.printStackTrace()
throw(e)
} finally {
jdbcConnection.close()
}
log.info 'data loaded'
H2备份工具只能备份H2数据库文件(不是MySQL数据库)。您没有设置源目录,因此该工具将尝试搜索当前工作目录下的H2数据库,该目录在您的案例中为“E:/ Workspace/opal”,并且没有找到H2数据库。 –