Mybatis异常:java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean

问题描述:

一月 15, 2014 3:43:13 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org[email protected]a530461: startup date [Wed Jan 15 15:43:13 CST 2014]; root of context hierarchy
一月 15, 2014 3:43:13 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring-mybatis.xml]
一月 15, 2014 3:43:14 下午 org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
信息: Loading properties file from class path resource [config.properties]
一月 15, 2014 3:43:14 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.s[email protected]4f430ea5: defining beans [dataSource,sqlSessionFactory,org.mybatis.spring.mapper.MapperScannerConfigurer#0,transactionManager,org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,userservice,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userservice‘: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void service.UserserviceImpl.setUserinfo(dao.UserinfoMapper); nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.mybatis.spring.SqlSessionFactoryBean] for bean with name ‘sqlSessionFactory‘ defined in class path resource [spring-mybatis.xml]; nested exception is java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105)
at test.Newtest.main(Newtest.java:15)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void service.UserserviceImpl.setUserinfo(dao.UserinfoMapper); nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.mybatis.spring.SqlSessionFactoryBean] for bean with name ‘sqlSessionFactory‘ defined in class path resource [spring-mybatis.xml]; nested exception is java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:600)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:92)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
... 9 more
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.mybatis.spring.SqlSessionFactoryBean] for bean with name ‘sqlSessionFactory‘ defined in class path resource [spring-mybatis.xml]; nested exception is java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1262)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1331)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:337)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:316)
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:187)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:856)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:813)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:730)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:558)
... 11 more
Caused by: java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:417)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1283)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1254)
... 20 more

解决方案:

  缺少jar包 mybatis-spring.jar

时间: 2024-12-12 02:35:48

Mybatis异常:java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean的相关文章

使用commons-net做FTP功能的异常 java.lang.ClassNotFoundException: org.apache.oro.text.regex.Malformed

最近使用Apache的commons-net.jar做FTP上传下载功能,点击“上传”的时候报错,如下: 1 java.lang.ClassNotFoundException: org.apache.oro.text.regex.Malformed 上网查,说法有两种,1:可能本地windows xp里的jdk是1.6.15编绎.打包的,用地与1.6.15的jdk运行报错,换成高于jdk1.6.15的jdk就可以运行了:2.缺少jakarta-oro-2.0.8.jar文件. 刚开始的时候,我试

Mybatis异常--java.lang.IllegalArgumentException: NO ENUM const class org.apache.ibatis.type.JdbcType.int

今天下午写代码时发现一直报错,找了半天都没找到错误原因. 最后才发现原来是XML配置错误,但是Mybatis不识别int的. 上Mybatis官网翻了翻才发现原来Mybatis的JdbcType全是大写,而且没有INT,只有INTEGER 以后注意,不能再写串了(╯‵□′)╯︵┻━┻ 好像oracle也有一些类型和Mybatis上定义的不一样,下次出了问题记得去查一下Mybatis中是怎样定义的了 原文地址:https://www.cnblogs.com/wcxcc/p/10734860.htm

spring异常 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet

情况1:工程没有添加jar包引用 情况2:(最雷人的错误~)你的工程jar包可能都是引用的,需要把它们手动拷贝到工程里来! 情况3:没有配置spring的映射Bean引用 情况4:spring bean配置的类在当前spring版本中没有

【报错】java.lang.ClassNotFoundException: org.apache.ibatis.session.SqlSession

报错 java.lang.ClassNotFoundException: org.apache.ibatis.session.SqlSession 或者 java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean 很明显  都是因为类找不到:SqlSession 这个类或者 SqlSessionFactoryBean找不到 解决方法: 整合ssm时忘记加上mybatis依赖以及mybatis-spring

真正解决问题:maven eclipse tomcat java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

在使用eclipse进行整合springmvc时经常会碰到这样的异常: java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener 这时里的意思是说找不到jar包,如果使用的是maven管理jar包,会发现jar包明明已经有了,但还是报错:如果mvn package生成一个war包发布到tomcat下面会发现,其实项目是没问题的. 1.出现这个问题的原因有可能的其中一点就是sprin

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoader

在使用eclipse进行整合springmvc时经常会碰到这样的异常: java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener 这时里的意思是说找不到jar包,如果使用的是maven管理jar包,会发现jar包明明已经有了,但还是报错:如果mvn package生成一个war包发布到tomcat下面会发现,其实项目是没问题的. 1.出现这个问题的原因有可能的其中一点就是sprin

maven eclipse tomcat java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoader

在使用eclipse进行整合springmvc时经常会碰到这样的异常: java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener 这时里的意思是说找不到jar包,如果使用的是maven管理jar包,会发现jar包明明已经有了,但还是报错:如果mvn package生成一个war包发布到tomcat下面会发现,其实项目是没问题的. 1.出现这个问题的原因有可能的其中一点就是sprin

eclipse运行maven项目报错java.lang.ClassNotFoundException: xxxxxx

在eclipse中运行maven项目,出现异常--java.lang.ClassNotFoundException: org.apache.shiro.web.env.EnvironmentLoaderListener.如果确认shiro相关的依赖jar无误,那么可以试着如下操作: 右键项目--build path--configure build path...--deployment assembly--add--java build path entries--maven dependen

疑惑的 java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()L

在MAVEN项目里面,在整合spring和mybatis在执行数据库操作的时候报出了: java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()L错误 在网上搜的大多说是jar包版本不兼容的问题.但想想,不应该啊,这是他们原有的系统,难道有做过升级吗,最后尝试着把版本升级了下,还真是版本兼容出了问题. 1 Exception in thread "main