我正在尝试将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'
}
有人知道为什么不匹配吗? 预先感谢
答案 0 :(得分:0)
类似两个不同依赖项的声音包括重复的jar。
在Gradle中似乎有一个管理依赖项的插件,看看here。
答案 1 :(得分:0)
从您的配置中删除版本:
compile("org.liquibase:liquibase-core")
让Spring Dependency Management帮您解决这个问题。
答案 2 :(得分:0)
就我而言,升级到同时使用Spring Boot 2.1.0.RELEASE
和org.liquibase:liquibase-core:3.6.3
可以完全解决问题。
答案 3 :(得分:0)
我在我的 Maven 项目中通过删除 POM 中的 Liquibase 版本解决了这个问题
{
"name": "reading-and-writing-files",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"start": "electron .",
"package-win": "electron-packager . electron-tutorial-app --overwrite --asar --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"Reading and Writing Files\""
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"electron": "11.2.0",
"electron-packager": "^15.2.0"
}
}
在没有版本的情况下保持这种方式,其余的由 Spring 来处理。