2

I am trying to configure liquibase in my project and to generate a difference file between the database and my entities but i have an error.

When i run liquibase diff I receive the next error:

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

The liquibase.properties file:

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

The build.gradle file:

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()
}

Is there some configuration that I am missing from the application?

Falvius
  • 47
  • 1
  • 1
  • 6
  • I see in documetation: https://docs.liquibase.com/workflows/database-setup-tutorials/hibernate.html that there are dependencies their maven example has that yours does not, for example: javax.validation.validation-api and org.javassist.javassist, not sure if that matters but maybe you have to install the driver manually as the docs imply? – ronak Dec 29 '20 at 20:48

1 Answers1

0

Try using the same versions such as:

compile "org.liquibase:liquibase-core:4.4.2"
compile "org.liquibase.ext:liquibase-hibernate5:4.4.2"
Ясир
  • 136
  • 1
  • 16