gpt4 book ai didi

hibernate - Grails似乎具有错误的 hibernate 依赖关系

转载 作者:行者123 更新时间:2023-12-02 15:28:32 27 4
gpt4 key购买 nike

我正在将Grails项目从2.3.5版本升级到grails 2.4.0。
由于我的应用程序在生产中有多个实例,因此我在git分支中进行了此升级。
因为我必须解决应用程序2.3.5版本上的问题,所以有时我必须切换回该版本。
突然1.3.5版本不再运行:

    BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/spi/RegionFactory

当我搜索此错误时,我发现这部分属于Hibernate 4.3.5.2依赖项,对于2.3.5版本,它不在BuildConfig.groovy中(但在2.4.0版本中)。
当我运行 grails dependency-report时,它显示如下:
    +--- org.grails.plugins:hibernate4:4.3.5.2
| \--- org.hibernate:hibernate-ehcache:4.3.5.Final
| \--- org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1
| \--- org.hibernate:hibernate-validator:5.0.3.Final
| \--- com.fasterxml:classmate:1.0.0
| \--- net.sf.ehcache:ehcache-core:2.4.8
| \--- org.jboss.logging:jboss-logging:3.1.0.GA
| \--- org.grails:grails-datastore-gorm-hibernate4:3.1.0.RELEASE
| \--- org.hibernate.common:hibernate-commons-annotations:4.0.4.Final
| \--- javax.validation:validation-api:1.1.0.Final

虽然我的BuildConfig看起来像这样:
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
grails.project.war.file = "target/${grails.util.Environment.current.name}-${appVersion}.war"
grails.project.dependency.resolver = "maven"

grails.tomcat.nio=true

grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsHome()
mavenLocal()

grailsPlugins()
grailsCentral()

// uncomment the below to enable remote dependency resolution
// from public Maven repositories
mavenCentral()
//mavenRepo "http://snapshots.repository.codehaus.org"
mavenRepo "http://repository.codehaus.org"
mavenRepo "https://oss.sonatype.org/content/repositories/snapshots/"

//for export plugin 1.6
mavenRepo "http://repo.grails.org/grails/core"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
// runtime 'mysql:mysql-connector-java:5.1.16'

runtime 'mysql:mysql-connector-java:5.1.21'
runtime 'com.github.groovy-wslite:groovy-wslite:0.7.1'

test 'junit:junit:4.11'
test 'org.hamcrest:hamcrest-all:1.3'
// runtime "org.jggug.kobo:kobo-commons:0.2"

//for export plugin 1.6
compile 'commons-beanutils:commons-beanutils:1.8.3'
}
plugins {
build ":tomcat:7.0.47"

// plugins for the compile step
compile ":scaffolding:2.0.1"
compile ':cache:1.1.1'
compile ':mail:1.0.1', {
excludes 'spring-test'
}
compile ":quartz2:2.1.6.2"
compile ":csv:0.3.1"
compile ":export:1.6"
// compile ":jasper:1.2.1"
compile ":jasper:1.6.1"
compile ":spring-security-core:1.2.7.3"

// plugins needed at runtime but not for compilation
runtime ":hibernate:3.6.10.6" // or ":hibernate4:4.1.11.1"
runtime ":database-migration:1.3.8"
runtime ":jquery:1.10.2"
compile ":jquery-ui:1.10.3"
runtime ":resources:1.2.1"
compile ":events-push:1.0.M7"
// compile ":ajax-uploader:1.1"

// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"

compile ':cache:1.0.0'
}
}

如您所见,那里没有hibernate4:4.3.5.2。
我试图删除.m2目录和.grails目录,以刷新依赖关系,但是没有用。

但是,在我的笔记本电脑上,我还没有使用grails 2.4.0分支,因此一切正常!该依赖关系图仅显示了预期的休眠3.6.10.6依赖关系。

有谁知道这怎么可能?

最佳答案

如果要在同一工作空间中的git分支之间来回切换,应删除target目录,并使用与您最近切换到的分支对应的Grails版本重建代码。我不能仅凭此处提供的信息确定地说,而是取决于可能解决您问题的其他一些因素。

关于hibernate - Grails似乎具有错误的 hibernate 依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24054493/

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