今天对spring和mybatis整合进行练习,通过MapperScannerConfigurer进行mapper扫描

但是在进行单元测试的时候,死活就是报错,具体报错如下:

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [G:\idea_file\Spring_MyBatis\out\production\Spring_MyBatis\com\company\ssm\mapper\UserMapper.class]; nested exception is java.lang.IllegalArgumentException

at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:281)

    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)

    at org.mybatis.spring.mapper.ClassPathMapperScanner.doScan(ClassPathMapperScanner.java:155)

    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.scan(ClassPathBeanDefinitionScanner.java:220)

    at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:315)

    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)

    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)

    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)

    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)

    at com.company.ssm.test.UserMapperTest.setUp(UserMapperTest.java:16)

    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:483)

    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)

    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)

    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)

    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)

    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)

    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

    at org.junit.runners.ParentRunner.run(ParentRunner.java:292)

    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)

    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)

    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)

    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)

    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Caused by: java.lang.IllegalArgumentException

    at org.springframework.asm.ClassReader.<init>(Unknown Source)

    at org.springframework.asm.ClassReader.<init>(Unknown Source)

    at org.springframework.asm.ClassReader.<init>(Unknown Source)

    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:52)

    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)

    at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101)

    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:257)

    ... 31 more

刚开始我也很纳闷,后来到网上看了一下,原来是jdk版本(1.80)和整合包(mybatis-spring-1.2.2.jar)的版本不兼容

解决方法1:替换整合jar包为更高版本的jar,如4.2.6的jar包【有兴趣的同学可以自己替换下】

解决方法2:把jdk的版本更换为1.7【因为我的电脑上同时安装了jdk1.7和jdk1.8,所以我就直接替换为jdk1.7,问题就解决了】

运行测试代码

spring和mybatis整合遇到org.springframework.beans.factory.BeanDefinitionStoreException的更多相关文章

  1. mybatis+spring+springMVC处理org.springframework.beans.factory.BeanDefinitionStoreException:java.lang.IllegalArgumentException异常

    java.lang.IllegalArgumentException异常有三种情况 org.springframework.beans.factory.BeanDefinitionStoreExcep ...

  2. Sturts2整合Spring报错:org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml];

    十一月 17, 2019 1:11:44 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin警告: [SetPropertiesRul ...

  3. org.springframework.beans.factory.BeanDefinitionStoreException异常

    1.下面是我遇到的异常信息: 2017-03-25 18:01:11,322 [localhost-startStop-1][org.springframework.web.context.Conte ...

  4. org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/lonecloud/tomcat/apache-tomcat-7.0.70 2/webapps/myproject/WEB-INF/classes/cn/lone

    解决这个报错的解决办法: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidat ...

  5. org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL

    [报错] org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XM ...

  6. 3org.springframework.beans.factory.BeanDefinitionStoreException异常

    1.下面是我遇到的异常信息: 2017-03-25 18:01:11,322 [localhost-startStop-1][org.springframework.web.context.Conte ...

  7. Spring---加载配置文件的几种方法(org.springframework.beans.factory.BeanDefinitionStoreException)

    Spring中的几种容器都支持使用xml装配bean,包括:XmlBeanFactory ,ClassPathXmlApplicationContext ,FileSystemXmlApplicati ...

  8. ERROR [localhost-startStop-1] - Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/ap

    ERROR [localhost-startStop-1] - Context initialization failed org.springframework.beans.factory.Bean ...

  9. org.springframework.beans.factory.BeanDefinitionStoreException

    org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'd ...

随机推荐

  1. Online开发初体验——Jeecg-Boot 在线配置图表

    Online开发——初体验(在线配置图表) 01 通过JSON数据,快速配置图形报表 02 通过SQL数据,快速配置图形报表 03 图表模板配置,实现不同数据源图表合并展示 04 图表布局,支持单排. ...

  2. 查询sitemap中重复的记录

    ; ;

  3. Python学习day39-并发编程(各种锁)

    figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...

  4. Django项目: 4.用户登录登出功能

    用户登录登出功能 一.功能需求分析 1. 登录退出功能分析 流程图 功能 登录页面 登录功能 退出功能 二.登录页面 1. 接口设计 接口说明 类目 说明 请求方法 GET url定义 /user/l ...

  5. 04-2-object类型

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 初识莫队——小Z的袜子

    以前一直觉得莫队是多么高大上的一种算法,然而仔细看了下发现其实并不复杂,实质上就是技巧性的暴力美学. 在我看来莫队是一种分块排序后降低复杂度的算法,当答案可以通过左右端点一个一个移动维护出来的时候就可 ...

  7. webpack 4.0尝鲜

    发布不久得webpack 4.0据说速度快了68% - 98%,然后还支持没配置文件,所以看起来很牛逼得样子 所以尝试一发 webpack和webpack-cli分离 现在执行webpack命令 必须 ...

  8. psu online course

    https://onlinecourses.science.psu.edu/statprogram/programs Graduate Online Course Overviews Printer- ...

  9. Java虚拟机原理图解-- 1.1、class文件基本组织结构 [转]

    作为Java程序猿,我们知道,我们写好的.java 源代码,最后会被Java编译器编译成后缀为.class的文件,该类型的文件是由字节组成的文件,又叫字节码文件.那么,class字节码文件里面到底是有 ...

  10. C#获取C# DLL中的指定接口的所有实现实例 - qq_19759475的博客 - CSDN博客

    原文:C#获取C# DLL中的指定接口的所有实现实例 - qq_19759475的博客 - CSDN博客 public static List<T> CreateTarInterface& ...