JHipster 示例 Gradle App liquibaseDiffChangelog 命令抛出 "Driver class was not specified" 异常
JHipster Sample Gradle App liquibaseDiffChangelog command is throwing a "Driver class was not specified" exception
我正在尝试让 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 的 guide 中描述的参数相似。
在这个过程中是否还有其他步骤是我遗漏的,而且我在任何地方都找不到相关记录?
我是否需要单独下载 MySQL 连接器并将其放置在特定位置?
JHipster Liquibase documentation 没有提到任何其他步骤。
问题是您还需要针对您的 liquibase 配置 url 应该 运行 差异。您需要编辑的配置文件位于应用程序根目录 gradle 文件夹中的 liquibase.gradle:
args "--changeLogFile=src/main/resources/config/liquibase/changelog/" + buildTimestamp() +"_changelog.xml"
args "--referenceUrl=hibernate:spring:io.github.jhipster.sample.domain?dialect=&hibernate.ejb.naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy"
args "--username=jhipsterGradleSampleApplication"
args "--password="
args "--url=jdbc:mysql://localhost:3306/yourDB"
args "--driver=com.mysql.jdbc.Driver"
args "diffChangeLog"
您需要更改 url、用户名和密码才能使用您的数据库。干杯!
使用o
?dialect=org.hibernate.dialect.MySQL5InnoDBDialect"
我正在尝试让 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 的 guide 中描述的参数相似。
在这个过程中是否还有其他步骤是我遗漏的,而且我在任何地方都找不到相关记录?
我是否需要单独下载 MySQL 连接器并将其放置在特定位置?
JHipster Liquibase documentation 没有提到任何其他步骤。
问题是您还需要针对您的 liquibase 配置 url 应该 运行 差异。您需要编辑的配置文件位于应用程序根目录 gradle 文件夹中的 liquibase.gradle:
args "--changeLogFile=src/main/resources/config/liquibase/changelog/" + buildTimestamp() +"_changelog.xml"
args "--referenceUrl=hibernate:spring:io.github.jhipster.sample.domain?dialect=&hibernate.ejb.naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy"
args "--username=jhipsterGradleSampleApplication"
args "--password="
args "--url=jdbc:mysql://localhost:3306/yourDB"
args "--driver=com.mysql.jdbc.Driver"
args "diffChangeLog"
您需要更改 url、用户名和密码才能使用您的数据库。干杯!
使用o
?dialect=org.hibernate.dialect.MySQL5InnoDBDialect"