【问题标题】:How to generate change log file in liquibase using Java如何使用 Java 在 liquibase 中生成更改日志文件
【发布时间】:2014-08-25 16:46:05
【问题描述】:

我想用Java在liquibase中生成一个变更日志XML文件,里面存储了两个数据库差异的信息。

我的代码是:

Database database=CommandLineUtils.createDatabaseObject(MySQLConnection.class.getClassLoader(), 
                "jdbc:mysql://localhost:3306/test", "root", "admin", "com.mysql.jdbc.Driver", "", null,false,false,null,null,null,null);

        Database database2=CommandLineUtils.createDatabaseObject(MySQLConnection.class.getClassLoader(), 
                "jdbc:mysql://localhost:3306/pizzashop", "root", "admin", "com.mysql.jdbc.Driver", "", null,false,false,null,null,null,null);
      CommandLineUtils.doDiffToChangeLog("changelog.xml", database2, database,new DiffOutputControl(),null,null);

但它会生成一个空白的changelog.xml 文件。

【问题讨论】:

  • 现在,上面的脚本中有一个错字,将输出发送到“chagelog.xml”而不是“changelog.xml”,但这可能只是一个错字。
  • 我改了代码,结果还是一样
  • 能否在 liquibase 属性文件中设置 logLevel=DEBUG,然后附加日志?

标签: java liquibase


【解决方案1】:

我解决了我的问题。使用 liquibase 2.0.3 版本。

代码是:

Database database=CommandLineUtils.createDatabaseObject(MySQLConnection.class.getClassLoader(), 
                "jdbc:mysql://localhost:3306/lportal", "root", "admin", "com.mysql.jdbc.Driver", 
                null,null,null);

        Database database2=CommandLineUtils.createDatabaseObject(MySQLConnection.class.getClassLoader(), 
                "jdbc:mysql://localhost:3306/llportal", "root", "admin", "com.mysql.jdbc.Driver",
                null,null,null);
    CommandLineUtils.doDiffToChangeLog("changeLogFile.xml",database, database2)

;

【讨论】:

    猜你喜欢
    • 2020-02-16
    • 2013-09-29
    • 2011-03-18
    • 2015-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-24
    相关资源
    最近更新 更多