Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

liquibase.integration.spring.SpringLiquibase is available from 2 locations error in spring boot

I'm trying to integrate spring boot with liquibase, but when I run the application it throws the following error:

An attempt was made to call the method liquibase.integration.spring.SpringLiquibase.setLiquibaseSchema(Ljava/lang/String;)V but it does not exist. Its class, liquibase.integration.spring.SpringLiquibase, is available from the following locations:

    jar:file:/C:/Users/Dev/.gradle/caches/modules-2/files-2.1/org.liquibase/liquibase-core/3.5.5/c65051f327382018bd09c30380f25eac96f210da/liquibase-core-3.5.5.jar!/liquibase/integration/spring/SpringLiquibase.class

It was loaded from the following location:

    file:/C:/Users/Dev/.gradle/caches/modules-2/files-2.1/org.liquibase/liquibase-core/3.5.5/c65051f327382018bd09c30380f25eac96f210da/liquibase-core-3.5.5.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of liquibase.integration.spring.SpringLiquibase

It looks like that the problem is given by spring-boot-starter-data-jpa, as soon as I remove the dependency, the application runs fine. This is my full dependency list, but I would also need JPA to write my persistence classes.

dependencies {
        compile('org.springframework.boot:spring-boot-starter-actuator')
        compile 'org.springframework.boot:spring-boot-starter-web'

        runtime('org.postgresql:postgresql:42.2.5')

        compile 'org.webjars:bootstrap:4.1.3'
        compile 'org.webjars:webjars-locator-core'

        compile("org.springframework.boot:spring-boot-starter-data-jpa")
        compile("org.hibernate:hibernate-entitymanager:4.3.4.Final")
        compile("org.hibernate:hibernate-validator:6.0.16.Final")
        compile ("org.hibernate:hibernate-core:5.4.1.Final")

        testCompile 'org.springframework.boot:spring-boot-starter-test'

        compile("org.liquibase:liquibase-core:3.5.5")

        liquibaseRuntime 'org.liquibase:liquibase-gradle-plugin:2.0.1'
        liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.0.2'
        liquibaseRuntime "org.liquibase:liquibase-core:3.5.5"
        liquibaseRuntime 'org.postgresql:postgresql:42.2.5'
    }

Any idea why there's a mismatch? Thanks in advance

like image 755
user3353167 Avatar asked Dec 03 '22 10:12

user3353167


2 Answers

Remove the version from your configuration:

compile("org.liquibase:liquibase-core")

Let Spring Dependency Management take care of that for you.

like image 120
Rafa Avatar answered Dec 21 '22 12:12

Rafa


I solved it in my maven project just by removing the Liquibase version in the POM

<dependency>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-core</artifactId>
</dependency>

Leave it this way without the version and Spring takes care of the rest.

like image 31
Guilherme Gehling Avatar answered Dec 21 '22 13:12

Guilherme Gehling