我使用SpringLiquibase进行液化配置,下面的配置可以很好地处理单个changelog文件(sql格式化)
@Configuration
@Slf4j
public class LiquibaseConfiguration {
@Inject
private DataSource dataSource;
@Bean
public SpringLiquibase liquibase() {
log.info("################## Entering into liquibase #################");
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setDataSource(dataSource);
liquibase.setChangeLog("classpath:schema/update-schema-01.sql");
// Configure rest of liquibase here...
// ...
return liquibase;
}
}在我的应用程序中,我可能需要运行more than one changelog文件,但无法执行,
我试着给多个变色龙喂食,
liquibase.setChangeLog("classpath:schema/update-schema-01.sql"); liquibase.setChangeLog("classpath:schema/update-schema-02.sql");
最后一个变更文件单独被执行。
liquibase.setChangeLog("classpath:schema/*.sql");
作为liquibase.exception.ChangeLogParseException: java.io.IOException: Found 2 files that match classpath:schema/*.sql获取错误
请建议一种方法,在这里的includeAll变化。
发布于 2019-05-24 12:37:51
可能的解决方案之一是:您可以创建主changelog,它将尽可能多地包括其他changelogs。在SpringLiquibase对象中,您将只设置一个主液化基变化量。
例如,假设您有2个changelog文件:one-changelog.xml和two-changelog.xml,并且需要同时运行这两个文件。我建议您再创建一个文件main-changelog.xml,其中包括one-changelog.xml和two-changelog.xml文件,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<include file="one.xml"/>
<include file="two.xml"/>
</databaseChangeLog>并将main-changelog.xml文件设置为SpringLiquibase的changelog。
因此,您将有两个单独的变更日志文件。
https://stackoverflow.com/questions/56292517
复制相似问题