【发布时间】:2014-06-05 07:46:08
【问题描述】:
我正在将我的 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 依赖关系。
有人知道这怎么可能吗?
【问题讨论】:
标签: hibernate grails dependency-management