微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

LiquiBase-找不到数据库驱动程序liquibase.ext.hibernate.database.connection.HibernateDriver

如何解决LiquiBase-找不到数据库驱动程序liquibase.ext.hibernate.database.connection.HibernateDriver

我正在尝试在项目中配置liquibase并在数据库和实体之间生成差异文件,但是我遇到了错误

当我运行 liquibase diff 时,我收到下一个错误

Starting Liquibase at 09:24:42 (version 4.1.1 #10 built at 2020-10-12 19:24+0000)
Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: liquibase.ext.hibernate.database.connection.HibernateDriver
For more information,please use the --logLevel flag

liquibase.properties文件

url=jdbc:sqlserver://localhost:1490;databaseName=Explorers
username=sa
password=pwd_Admin
driver=com.microsoft.sqlserver.jdbc.sqlServerDriver
classpath=sqljdbc42.jar
referenceUrl=hibernate:spring:com.example.explorers.domain?dialect=org.hibernate.dialect.sqlServer2012Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
changeLogFile=..\\db\\db.changelog-master.xml

build.gradle文件

plugins {
    id 'org.springframework.boot' version '2.2.0.RELEASE'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'java'
    id 'war'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '8'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.liquibase.ext:liquibase-hibernate5:3.6"
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compile group: 'org.springframework.boot',name: 'spring-boot-starter-data-jpa',version: '2.3.5.RELEASE'
    implementation 'com.microsoft.sqlserver:mssql-jdbc'
    implementation 'org.hibernate:hibernate-core'
    implementation 'org.hibernate:hibernate-entitymanager'
    implementation 'org.hibernate:hibernate-envers'
    implementation group: 'org.hibernate',name: 'hibernate-validator',version: '6.0.12.Final'
    compile(group: 'org.liquibase',name: 'liquibase-core',version: "4.1.1")
    compile group: 'org.liquibase.ext',name: 'liquibase-hibernate5',version: '3.6'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage',module: 'junit-vintage-engine'
    }
}

test {
    useJUnitPlatform()
}

应用程序中缺少某些配置吗?

解决方法

尝试使用相同的版本,例如:

compile "org.liquibase:liquibase-core:4.4.2"
compile "org.liquibase.ext:liquibase-hibernate5:4.4.2"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。