简体   繁体   English

liquibase.exception.ChangeLogParseException:ChangeLogFile不存在

[英]liquibase.exception.ChangeLogParseException: ChangeLogFile does not exists

public static void main(String[] args) throws Exception {
    //execute("jdbc:postgresql://localhost:5432/JAVA_Test", "Admin", "123456", "org.postgresql.Driver");
    execute("jdbc:jtds:sqlserver://localhost:5432/Liquibase_JAVA", "sa", "123456!", "net.sourceforge.jtds.jdbc.Driver");
}

public static void execute(String url, String userName, String password, String driver) throws Exception  {
    DatabaseConnection dbConnection = new DatabaseConnection(url, driver, userName, password);
    Connection conn = dbConnection.getConnection();
    Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(conn));
    String changeLog = "/job_executor/liquibasechangelog/databaseChangeLog.xml";
    Liquibase liquibase = new Liquibase(changeLog, new FileSystemResourceAccessor(), database);
    liquibase.update(null);
    conn.close();
}

I have my changeLogFile inside my project. 我的项目中有我的changeLogFile。 It's kind of weird that i'm getting an error changeLogFile.xml does not exists. 我收到错误changeLogFile.xml不存在有点奇怪。

Can anyone help me with this, THanks 有人可以帮我吗,谢谢

Most likely your change log file is not there: 您的更改日志文件很可能不存在:

/job_executor/liquibasechangelog/databaseChangeLog.xml

but there: 但是那里:

job_executor/liquibasechangelog/databaseChangeLog.xml

Please notice the / missing in the second path so it will be relative, not absolute. 请注意第二个路径中的/,因此它将是相对的,而不是绝对的。

I have fixed it, by adding the liquibasechangelog folder (where my xml files resides) to the build path and then by referring it just by the file name instead of path to the file name 我已修复此问题,方法是将liquibasechangelog文件夹(我的xml文件所在的文件夹)添加到构建路径,然后仅通过文件名而不是文件名路径来引用它

just like this 像这样

String changeLog = "databaseChangeLog.xml"; 字符串changeLog =“ databaseChangeLog.xml”;

THanks @DavidX @MichalRorat 谢谢@DavidX @MichalRorat

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM