在Wix嵌入式MySql上运行Liquibase
目前,我有一些使用Spring Boot和H2嵌入式数据库进行功能测试的新模块 遗留模块使用大量Liquibase脚本构建整个数据库 我希望使用它使测试数据库更像生产数据库。在阅读了文档之后,我没有找到任何关于如何使用Liquibase或Flyway等工具处理脚本的具体信息在Wix嵌入式MySql上运行Liquibase,mysql,spring-boot,liquibase,embedded-database,Mysql,Spring Boot,Liquibase,Embedded Database,目前,我有一些使用Spring Boot和H2嵌入式数据库进行功能测试的新模块 遗留模块使用大量Liquibase脚本构建整个数据库 我希望使用它使测试数据库更像生产数据库。在阅读了文档之后,我没有找到任何关于如何使用Liquibase或Flyway等工具处理脚本的具体信息 在他启动之后,是否可以在这个嵌入式数据库上执行Liquibase目标?经过几天的研究,是的,有一种方法可以在Wix嵌入式MySQL上运行Liquibase 以下是一步一步的步骤: 配置Wix嵌入式数据库 Wix的配置非常简单
在他启动之后,是否可以在这个嵌入式数据库上执行Liquibase目标?经过几天的研究,是的,有一种方法可以在Wix嵌入式MySQL上运行Liquibase 以下是一步一步的步骤: 配置Wix嵌入式数据库 Wix的配置非常简单,如其上所述: 液化酶构型 我在我的项目中添加了,因此我们可以通过编程方式访问Liquibase代码,可以在这里找到 首先,我们必须构建一个并传递给Liquibase,以找到数据库的正确实现,然后我们可以操作Liquibase对象来执行以下目标:
DataSourceBuilder<?> dataSourceBuilder = DataSourceBuilder.create();
dataSourceBuilder.username(mysqld.getConfig().getUsername());
dataSourceBuilder.password(mysqld.getConfig().getPassword());
dataSourceBuilder.driverClassName(com.mysql.jdbc.Driver.class.getName());
dataSourceBuilder.url("jdbc:mysql://localhost:3060/myschema");
DataSource dataSource = dataSourceBuilder.build();
Database database = DatabaseFactory
.getInstance()
.findCorrectDatabaseImplementation(
new JdbcConnection(dataSource.getConnection()) // Fetch MySQL database implementation
);
Liquibase liquibase = new Liquibase("liquibase/mychanges.xml", // Path to liquibase changes
new ClassLoaderResourceAccessor(),
database);
liquibase.update(new Contexts()); // This execute the liquibase:update on the embedded database
DataSourceBuilder DataSourceBuilder=DataSourceBuilder.create();
dataSourceBuilder.username(mysqld.getConfig().getUsername());
dataSourceBuilder.password(mysqld.getConfig().getPassword());
dataSourceBuilder.driverClassName(com.mysql.jdbc.Driver.class.getName());
dataSourceBuilder.url(“jdbc:mysql://localhost:3060/myschema");
DataSource DataSource=dataSourceBuilder.build();
数据库=数据库工厂
.getInstance()
.findCorrectDatabaseImplementation(
新建JdbcConnection(dataSource.getConnection())//获取MySQL数据库实现
);
Liquibase Liquibase=new Liquibase(“Liquibase/mychanges.xml”,//Liquibase更改的路径
新建ClassLoaderResourceAccessor(),
数据库);
liquibase.update(新上下文());//这将在嵌入式数据库上执行liquibase:update
DataSourceBuilder<?> dataSourceBuilder = DataSourceBuilder.create();
dataSourceBuilder.username(mysqld.getConfig().getUsername());
dataSourceBuilder.password(mysqld.getConfig().getPassword());
dataSourceBuilder.driverClassName(com.mysql.jdbc.Driver.class.getName());
dataSourceBuilder.url("jdbc:mysql://localhost:3060/myschema");
DataSource dataSource = dataSourceBuilder.build();
Database database = DatabaseFactory
.getInstance()
.findCorrectDatabaseImplementation(
new JdbcConnection(dataSource.getConnection()) // Fetch MySQL database implementation
);
Liquibase liquibase = new Liquibase("liquibase/mychanges.xml", // Path to liquibase changes
new ClassLoaderResourceAccessor(),
database);
liquibase.update(new Contexts()); // This execute the liquibase:update on the embedded database