Run Migrator pulling changelogs from a .JAR file (Spring boot)

Hi, 

I have Spring boot Jar application with changelogs inside the jar.

I want to run updateSQL command with command line.

Is it possible?

Thx

I believe this is possible, but I am not certain of the exact commands and where in the jar file the changelogs should be located. It would most likely involve listing the jar with the changelogs as part of the classpath.

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Excellent - seeing what you actually did and what errors happened is super helpful. 

The problem you are habing now is because the mysql driver jar is not on the classpath. You would need to do something like this:

java -jar liquibase.jar --driver=com.mysql.jdbc.Driver --classpath=myapplication.jar;mysqldriver.jar --changeLogFile=/liquibase/current-changelog.xml  --url=jdbc:mysql://localhost/liquibase --username=root --password=root updateSQL > /tmp/script.sql

Inside your myapplication.jar, I think you would need to have (root)/liquibase/current-changelog.xml

Solving the first problem will get you further and may reveal other issues. 

Steve Donie Principal Software Engineer Datical, Inc. http://www.datical.com/

Can you show me the command that you used? In general, whenever reporting a problem, you should always include three things:

  1. This is what I did

  2. This is what actually happened

  3. This is what I expected to happen

“It doesn’t work” isn’t super helpful, because I don’t know what “It” is.

In this case, if “It” is the exact command I gave you, then the problem could be the separator used in that command - rather than a semicolon, it might need to be a colon (if you are on unix-like OS). 

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

I tried the following :

java -jar liquibase.jar --driver=com.mysql.jdbc.Driver --classpath=myapplication.jar --changeLogFile=/liquibase/current-changelog.xml  --url=jdbc:mysql://localhost/liquibase --username=root --password=root updateSQL > /tmp/script.sql

And I got the error :

Cannot find database driver: com.mysql.jdbc.Driver

Hi Steve

It doesn’t work

I got :

mysql-connector-java-5.1.34.jar: command not found

Any ideas?

Hi Steve,

Now It works with :

java -jar liquibase.jar --driver=com.mysql.jdbc.Driver --classpath=myapplication.jar: mysqldriver.jar  --changeLogFile=/liquibase/current-changelog.xml  --url=jdbc:mysql://localhost/liquibase --username=root --password=root updateSQL > /tmp/script.sql

Thx a lot

1 Like