我认为标题解释了这一切:有没有一种很好的方法来使用 SchemaCrawler 创建和加载数据库模式的离线快照而不使用命令行?如果是,您能否提供一些示例代码/链接?如果没有,一些使用命令行选项的示例 java 代码也会有所帮助(我对此没有太多经验)!
感谢您提供任何帮助!
PS:我设法用这段代码创建了离线快照:
final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
// Set what details are required in the schema - this affects the
// time taken to crawl the schema
options.setSchemaInfoLevel(SchemaInfoLevelBuilder.standard());
options.setRoutineInclusionRule(new ExcludeAll());
options.setSchemaInclusionRule(new RegularExpressionInclusionRule(/* some regex here*/));
options.setTableInclusionRule(new RegularExpressionExclusionRule(/*some regex here*/));
outputOptions.setCompressedOutputFile(Paths.get("./test_db_snapshot.xml"));
final String command = "serialize";
final Executable executable = new SchemaCrawlerExecutable(command);
executable.setSchemaCrawlerOptions(options);
executable.setOutputOptions(outputOptions);
executable.execute(getConnection());
不知道如何连接到它。