在我的〜/ .bashrc中:
export CLASSPATH=~/mysqljdbc/mysql-connector-java-5.1.21-bin.jar
CLASSPATH var是正确的:
ray@ubuntu:~$ echo $CLASSPATH
/home/ray/mysqljdbc/mysql-connector-java-5.1.21-bin.jar
尝试运行它:
ray@ubuntu:/var/www/project$ sh ~/flyway-commandline-1.7/flyway.sh -driver=com.mysql.jdbc.Driver -user=root -p=password -url=jdbc:mysql://localhost:3306/project init
Flyway (Command-line Tool) v.1.7
FlywayException: Unable to instantiate jdbc driver: com.mysql.jdbc.Driver
Occured in com.googlecode.flyway.core.util.jdbc.DriverDataSource.<init>() at line 93
为什么它找不到驱动程序的任何想法?
谢谢!
答案 0 :(得分:2)
指定-classpath或-cp会覆盖CLASSPATH的任何设置,这在flyway.sh中完成 根据{{3}},你必须将你的mysql jdbc jar存储在jars文件夹中(或者只是将它添加到flyway.sh中的JVM启动)。