Nó phải là một cái gì đó tương tự (lấy từ nguồn liquibase.integration.spring.SpringLiquibase):
java.sql.Connection c = YOUR_CONNECTION;
Liquibase liquibase = null;
try {
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(c))
liquibase = new Liquibase(YOUR_CHANGELOG, new FileSystemResourceAccessor(), database);
liquibase.update();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
if (c != null) {
try {
c.rollback();
c.close();
} catch (SQLException e) {
//nothing to do
}
}
}
Có nhiều thi hành ResourceAccessor tùy thuộc vào cách các file changelog của bạn nên được tìm thấy.
Nguồn
2012-05-16 21:16:30
Bạn đã xem http://forum.liquibase.org/topic/using-liquibase-directly-from-java chưa? – artbristol