【问题标题】:liquibase.integration.spring.SpringLiquibase is available from 2 locations error in spring bootliquibase.integration.spring.SpringLiquibase 可从 Spring Boot 中的 2 个位置错误获取
【发布时间】:2019-08-28 23:21:24
【问题描述】:

我正在尝试将 spring boot 与 liquibase 集成,但是当我运行应用程序时,它会引发以下错误:

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

看起来问题是由 spring-boot-starter-data-jpa 给出的,只要我删除依赖项,应用程序就可以正常运行。这是我的完整依赖列表,但我还需要 JPA 来编写我的持久性类。

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'
    }

知道为什么会出现不匹配吗? 提前致谢

【问题讨论】:

    标签: spring-boot spring-data-jpa build.gradle liquibase


    【解决方案1】:

    我在我的 maven 项目中解决了这个问题,只是在 POM 中删除了 Liquibase 版本

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

    保持这种方式没有版本,其余的由 Spring 处理。

    【讨论】:

      【解决方案2】:

      就我而言,升级到同时使用 Spring Boot 2.1.0.RELEASEorg.liquibase:liquibase-core:3.6.3 完全解决了这个问题。

      【讨论】:

        【解决方案3】:

        从您的配置中删除版本:

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

        让 Spring 依赖管理为您解决这个问题。

        【讨论】:

          【解决方案4】:

          听起来两个不同的依赖项包括一个重复的 jar。

          Gradle中好像有管理依赖的插件,看看here

          【讨论】:

            猜你喜欢
            • 2019-05-01
            • 2011-08-29
            • 2021-01-17
            • 1970-01-01
            • 2019-07-26
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多