spring+hibernate集成

问题描述

这是什么错误呀?请高手帮忙解决org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'userManager'definedinclasspathresource[applicationContext-beans.xml]:Cannotresolvereferencetobean'sessionFactory'whilesettingbeanproperty'sessionFactory';nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'sessionFactory'definedinclasspathresource[applicationContext-common.xml]:Initializationofbeanfailed;nestedexceptionisjava.lang.NoClassDefFoundError:org/hibernate/cache/CacheProvideratorg.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)atorg.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)atjava.security.AccessController.doPrivileged(NativeMethod)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)atorg.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)atorg.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)atcom.gwy.usermanager.manager.UserManagerImplTest.testAddUser(UserManagerImplTest.java:17)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:597)atjunit.framework.TestCase.runTest(TestCase.java:168)atjunit.framework.TestCase.runBare(TestCase.java:134)atjunit.framework.TestResult$1.protect(TestResult.java:110)atjunit.framework.TestResult.runProtected(TestResult.java:128)atjunit.framework.TestResult.run(TestResult.java:113)atjunit.framework.TestCase.run(TestCase.java:124)atjunit.framework.TestSuite.runTest(TestSuite.java:243)atjunit.framework.TestSuite.run(TestSuite.java:238)atorg.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)atorg.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)atorg.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)Causedby:org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'sessionFactory'definedinclasspathresource[applicationContext-common.xml]:Initializationofbeanfailed;nestedexceptionisjava.lang.NoClassDefFoundError:org/hibernate/cache/CacheProvideratorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)atjava.security.AccessController.doPrivileged(NativeMethod)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)atorg.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)...37moreCausedby:java.lang.NoClassDefFoundError:org/hibernate/cache/CacheProvideratjava.lang.Class.getDeclaredMethods0(NativeMethod)atjava.lang.Class.privateGetDeclaredMethods(Class.java:2427)atjava.lang.Class.getDeclaredMethods(Class.java:1791)atjava.beans.Introspector$1.run(Introspector.java:1272)atjava.security.AccessController.doPrivileged(NativeMethod)atjava.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1270)atjava.beans.Introspector.getTargetMethodInfo(Introspector.java:1136)atjava.beans.Introspector.getBeanInfo(Introspector.java:387)atjava.beans.Introspector.getBeanInfo(Introspector.java:159)atorg.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:220)atorg.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)atorg.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:252)atorg.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:259)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1132)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:992)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)...46moreCausedby:java.lang.ClassNotFoundException:org.hibernate.cache.CacheProvideratjava.net.URLClassLoader$1.run(URLClassLoader.java:200)atjava.security.AccessController.doPrivileged(NativeMethod)atjava.net.URLClassLoader.findClass(URLClassLoader.java:188)atjava.lang.ClassLoader.loadClass(ClassLoader.java:307)atsun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)atjava.lang.ClassLoader.loadClass(ClassLoader.java:252)atjava.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)...62more

解决方案

解决方案二:
java.lang.NoClassDefFoundError:org/hibernate/cache/CacheProvider应该是jar包冲突问题,检查一下有没有重复的jar包,删除低版本,保留高版本,顺便确定下有没有少jar。
解决方案三:
试过了,不行呀
解决方案四:
'userManager在context-bean.xml中的定义错误,估计你有引用属性没有设定吧

时间: 2024-11-08 23:31:24

spring+hibernate集成的相关文章

Struts2 spring hibernate 集成大问题

问题描述 在集成SSH出现以下错误,我已经将冲突jar包删除asm2.2.3,但还不不行!tomcat换成新的也不行!不是缓存的事情日志错误:11547mainERRORorg.springframework.web.context.ContextLoaderContextinitializationfailedorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'sessionFact

集成Flex,Spring,Hibernate构建应用程序

RIA(Rich Internet Application)-- 富 Internet 应用以其良好的客户体验得到越 来越广泛的应用,银行,电信等领域已有诸多成功案例.Adobe 的 Flex 是最具有代表性的 基于 Flash 的 RIA 技术.通过对 Flex 以及当前流行的 Spring.Hibernate 的 J2EE 开源 框架进行集成,使客户既能获得到一流的用户体验,又能获得 J2EE 应用的高稳定性,高可 扩展性和可移植性.从某种意义上来说,RIA 是未来 Web 应用的发展方向.

JSF+Spring+Hibernate的实例讲解

js 使用JavaServer Faces(JSF).Spring Framework和Hibernate建立一个真实的Web应用程序内容概要使用JSF建立一个真实的Web应用程序不是没有意义的任务,这篇文章介绍了如何将JSF与Sping Framework和Hibernate集成,并且给出了使用这些技术建立这个真实的Web应用程序的最佳实践和设计指导 JavaServer Faces(JSF)技术是J2EE应用程序的一个新的用户接口框架,它非常适合基于MVC(Model-View-Contro

Spring Boot集成JPA的Column注解命名字段无效的问题

偶然发现,Spring Boot集成jpa编写实体类的时候,默认使用的命名策略是下划线分隔的字段命名. Spring Boot版本:1.5.4.release 数据表: id int, userName varchar(50) 那么如下的映射: @Data @Entity @Table(name="t_users") @NoArgsConstructor @AllArgsConstructor @Accessors(chain=true) public class User { @Id

Spring,hibernate,struts经典面试笔试题(含答案)_java

本文讲述了Spring,hibernate,struts经典面试笔试题及其参考答案.分享给大家供大家参考,具体如下: 1.Hibernate工作原理及为什么要用? 原理: 1.读取并解析配置文件 2.读取并解析映射信息,创建SessionFactory 3.打开Sesssion 4.创建事务Transation 5.持久化操作 6.提交事务 7.关闭Session 8.关闭SesstionFactory 为什么要用: ① . 对JDBC访问数据库的代码做了封装,大大简化了数据访问层繁琐的重复性代

SSH---集成Struts2+Spring+Hibernate(一)

SSH---集成Struts2+Spring+Hibernate(一)           本方案让Spring创建Struts2的Action,不让Spring完全管理Struts2的Action,Struts2Action中的依赖对象,默认会根据名称自动装配           1.创建web项目           2.引入Struts2的依赖包,将依赖包拷贝到WEB-INF/lib下 *commons-logging-1.0.4.jar *freemarker-2.3.15.jar *o

ExtJS+SpringMVC+Spring+Hibernate的一种实现(蒋锋代码分析)

今天以前我写的java环境下web应用都是这种形式:1--自己写的@Controller中的handler方法采用Spring+Hibernate的方式读取数据,读取到我们自定义的PO中(从硬盘读取到内存中).2--然后采用SpringMVC的ModelAndView的方法addObject()将得到的PO或者PO的List放入ModelAndView的实例中.3--然后handler方法中setViewName(),return.相当于返回string或者4--ModelAndView给Spr

java-关于spring+hibernate 注入sessionFactory为null的问题

问题描述 关于spring+hibernate 注入sessionFactory为null的问题 最近一个项目需要用到struts2+spring+hibernate组合框架,我在一点一点的做配置,但做到注入SessionFactory时,一直不成功,在网上搜的一些解决方案也都不适用.故在此发布,希望高手们不吝赐教.web.xml的配置为: <?xml version=""1.0"" encoding=""UTF-8""

Struts+Spring+Hibernate实现上传下载

上传|下载 引言 文件的上传和下载在J2EE编程已经是一个非常古老的话题了,也许您马上就能掰着指头数出好几个著名的大件:如SmartUpload.Apache的FileUpload.但如果您的项目是构建在Struts+Spring+Hibernate(以下称SSH)框架上的,这些大件就显得笨重而沧桑了,SSH提供了一个简捷方便的文件上传下载的方案,我们只需要通过一些配置并辅以少量的代码就可以完好解决这个问题了. 本文将围绕SSH文件上传下载的主题,向您详细讲述如何开发基于SSH的Web程序.SS