我正在尝试让 Gradle liquibaseDiffChangelog 命令与JHipster Sample Gradle App一起使用,但出现以下异常:
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url ()
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:157)
at liquibase.integration.commandline.Main.doMigration(Main.java:915)
at liquibase.integration.commandline.Main.run(Main.java:180)
at liquibase.integration.commandline.Main.main(Main.java:99)
Caused by: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url ()
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:247)
at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:151)
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:85)
... 3 common frames omitted
Caused by: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url ()
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:199)
... 5 common frames omitted
:liquibaseDiffChangelog FAILED
我已将 liquibase.gradle 文件修改为以下内容以使用我的本地 MySQL 数据库:
configurations {
liquibase
}
dependencies {
liquibase group: 'org.liquibase.ext', name: 'liquibase-hibernate4', version: liquibase_hibernate4_version
}
task liquibaseDiffChangelog(dependsOn: compileJava, type: JavaExec) {
group = "liquibase"
classpath sourceSets.main.runtimeClasspath
classpath configurations.liquibase
main = "liquibase.integration.commandline.Main"
args "--changeLogFile=src/main/resources/config/liquibase/changelog/" + buildTimestamp() +"_changelog.xml"
args "--referenceUrl=hibernate:spring:com.mycompany.myapp.domain?dialect=org.hibernate.dialect.MySQL5Dialect"
args "--username=root"
args "--password=password"
args "--url=jdbc:mysql://localhost:3306/app"
args "--driver=com.mysql.jdbc.Driver"
args "diffChangeLog"
}
def buildTimestamp() {
def date = new Date()
def formattedDate = date.format('yyyyMMddHHmmss')
return formattedDate
}
这些参数看起来都是正确的,并且与本指南中描述的使用 Maven 的参数相似。
在这个过程中是否还有其他一些我遗漏的步骤并且我在任何地方都找不到记录?
我需要单独下载 MySQL 连接器并将其放置在某个位置吗?
JHipster Liquibase文档没有提到任何其他步骤。