我正在尝试使用JHipster Sample Gradle App使用Gradle liquibaseDiffChangelog命令,我收到以下异常:
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未提及任何其他步骤。
答案 0 :(得分:0)
问题是你还需要根据你的liquibase配置url来运行diff。您需要编辑的配置文件是liquibase.gradle,位于应用根目录的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"
您需要更改网址,用户名和密码才能使用您的数据库。干杯!
答案 1 :(得分:0)
使用o
?dialect=org.hibernate.dialect.MySQL5InnoDBDialect"