gpt4 book ai didi

hibernate - 无法使gradle获得liquibase-hibernate插件工作

转载 作者:行者123 更新时间:2023-12-03 05:47:29 44 4
gpt4 key购买 nike

尝试将liquibase:hibernate插件与spring-boot:gradle:postgres集成时,我在运行gradle diff命令时陷入了此错误。

Unexpected error running Liquibase: org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager

SEVERE 3/11/18 5:27 PM: liquibase: org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager
java.lang.NoClassDefFoundError: org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager
at liquibase.ext.hibernate.database.HibernateSpringPackageDatabase.createEntityManagerFactory(HibernateSpringPackageDatabase.java:69)
at liquibase.ext.hibernate.database.HibernateEjb3Database.buildMetadataFromPath(HibernateEjb3Database.java:51)
at liquibase.ext.hibernate.database.HibernateDatabase.buildMetadata(HibernateDatabase.java:136)
at liquibase.ext.hibernate.database.HibernateDatabase.setConnection(HibernateDatabase.java:75)
at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:131)
at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:151)
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:85)
at liquibase.integration.commandline.Main.createReferenceDatabaseFromCommandParams(Main.java:1283)
at liquibase.integration.commandline.Main.doMigration(Main.java:996)
at liquibase.integration.commandline.Main.run(Main.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:46)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:91)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.liquibase.gradle.LiquibaseTask.runLiquibase(LiquibaseTask.groovy:113)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

这是我的build.gradle:


buildscript {
ext {
springBootVersion = '2.0.0.RELEASE'
runList = 'main'
diffLog = '$projectDir/src/main/resources/db/changelog/db.changelog-master.xml'
}
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://repo.spring.io/libs-snapshot' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'org.liquibase:liquibase-gradle-plugin:1.2.4'
classpath 'org.liquibase:liquibase-core'
classpath 'org.postgresql:postgresql:42.2.1'
classpath 'org.liquibase.ext:liquibase-hibernate5:3.6'
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.liquibase.gradle'

group = 'com.project.sample'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
diffLog = '$projectDir/src/main/resources/db/changelog/db.changelog-{$version}.xml'

repositories {
mavenCentral()
}


dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.liquibase:liquibase-core')
compile('org.springframework.session:spring-session-core')
runtime('org.postgresql:postgresql')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}

liquibase {
activities {
//noinspection GroovyAssignabilityCheck
main {
changeLogFile project.ext.diffLog
url 'jdbc:postgresql://localhost:5432/quora'
username 'ueducation'
password 'u3duc@tion'
referenceUrl 'hibernate:spring:com.project.sample.src.main.web.entities?dialect=org.hibernate.dialect.PostgreSQL9Dialect'
referenceDriver 'liquibase.ext.hibernate.database.connection.HibernateDriver'
logLevel 'debug'
}
runList = project.ext.runList
}
}


版本:
  • Spring-data-jpa:2.0.5
  • 休眠:5.2.14
  • Liquibase-hibernate5插件:3.6

  • 我尝试遍历SO及其周围的许多帖子,但无法弄清楚。
    任何帮助表示赞赏。

    最佳答案

    因此,java.lang.NoClassDefFoundError表示该类未由类加载器加载。
    因此,只需将sprind-data-jpa添加到类路径。buildscript中更新的build.gradle看起来像

    buildscript {
    ext {
    springBootVersion = '2.0.0.RELEASE'
    runList = 'main'
    diffLog = '$projectDir/src/main/resources/db/changelog/db.changelog-master.xml'
    }
    repositories {
    mavenCentral()
    maven { url 'https://plugins.gradle.org/m2/' }
    maven { url 'https://repo.spring.io/libs-snapshot' }
    }
    dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath 'org.liquibase:liquibase-gradle-plugin:1.2.4'
    classpath 'org.liquibase:liquibase-core'
    classpath 'org.postgresql:postgresql:42.2.1'
    classpath 'org.liquibase.ext:liquibase-hibernate5:3.6'
    classpath 'org.springframework.data:spring-data-jpa:2.0.5.RELEASE'
    }

    }

    关于hibernate - 无法使gradle获得liquibase-hibernate插件工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49219899/

    44 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com