Failed to read candidate component class:file错误分析和处理

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\MyWorkspace\spring_mybatis1222\out\test\spring_mybatis1222\cn\itcast\ssm\mapper\UserMapperTest.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 cn.itcast.ssm.mapper.UserMapperTest.setUp(UserMapperTest.java:13)
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:498)
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

解决:

查看编译环境用的是1.8,将1.8降为1.7,问题解决,服务启动正常,

也就是说spring 3.2不支持1.8编译环境,解决办法就是降为1.7编译环境

spring官网说了,要使用java8,只支持spring 4.X以上版本,而spring的使用最低java要求java5及以上,

如果出现例外,那就例外说了,比如一开始spring 3.1就可以在java8上编译。
spring-asm包其实是不需要的,有的话,就删除

大概原因:

原因:spring3.2版本不支持jdk1.8,只能到jdk1.7;大概是asm有问题。

1、安装jdk1.7;

2、修改项目的编译级别为1.7 ;项目右键properties,选择 Java Compiler页面右侧选择1.7,并修改Project Facets中的java version为1.7

3、修改tomcat服务器所使用的jre:jre为1.7

4、重新部署

SpringMVC错误:Failed to read candidate component class:file... ...的更多相关文章

  1. 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 ...

  2. Eclipse项目修改编译jdk版本(Failed to read candidate component class: file 处理)

    转: Failed to read candidate component class: file 处理 2018年03月09日 07:15:54 爱萨萨 阅读数 10041   出错现象: org. ...

  3. spring在扫描包中的注解类时出现Failed to read candidate component错误

    出现:org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate componen ...

  4. spring3.2.0与mybatis3.2.7整合出错--Failed to read candidate component class--nested exception is java.lang.IllegalArgumentException

    错误信息如下: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate com ...

  5. TestNg和spring3测试报错:Failed to read candidate component class-遁地龙卷风

    java.lang.IllegalStateException:Failed to load ApplicationContext Caused by: org.springframework.bea ...

  6. Spring+Mybatis整合时 Failed to read candidate component class,Caused by:IllegalArgumentException

    Spring+Mybatis整合时Caused by: java.lang.IllegalArgumentException错误 org.springframework.beans.factory.B ...

  7. spring 启动异常Failed to read candidate component class

    Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: ...

  8. Failed to read candidate component class错误分析

    org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component c ...

  9. SSM项目启动报错:Failed to read candidate component class

    SSM项目启动报错:Failed to read candidate component class 换成3.1又没有问题,换成3.2又不行,查看编译环境用的是1.8,将1.8降为1.7,问题解决,服 ...

随机推荐

  1. Vue-cli中axios传参的方式以及后端取的方式

    0917自我总结 Vue-cli中axios传参的方式以及后端取的方式 一.传参 params是添加到url的请求字符串中的,用于get请求. data是添加到请求体(body)中的, 用于post请 ...

  2. Windows常用操作

    目录 查询IP地址 常用快捷键 显示文件后缀名 查询IP地址 1.进入到dos界面 2.输入命令: ipconfig 常用快捷键 快捷键 作用 win+E 打开计算机 win+R 打开运行 win+R ...

  3. 数据结构5_java---二叉树,树的建立,树的先序、中序、后序遍历(递归和非递归算法),层次遍历(广度优先遍历),深度优先遍历,树的深度(递归算法)

    1.二叉树的建立 首先,定义数组存储树的data,然后使用list集合将所有的二叉树结点都包含进去,最后给每个父亲结点赋予左右孩子. 需要注意的是:最后一个父亲结点需要单独处理 public stat ...

  4. 我的Python学习方向-前端辅助-后端框架django学习-浅谈(一)

    初始python,很直观的感受是编译格式多样,代码简介易懂 作为一门通用编程语言,python能编写多种用途的编程语言,当然对于我目前,我的方向便是借助其前端编辑器,实现后台框架的连接学习 1.首先便 ...

  5. 深copy

    更好的对一个对象进行复制 using System; using System.Collections.Generic; using System.Linq; using System.Text; u ...

  6. webpack 4 移除 CommonsChunkPlugin,取而代之的是两个新的配置项(optimization.splitChunks 和 optimization.runtimeChunk

    默认方式 webpack模式模式现在已经做了一些通用性优化,适用于多数使用者. 需要注意的是:默认模式只影响按需(on-demand)加载的代码块(chunk),因为改变初始代码块会影响声明在HTML ...

  7. 【Bug】解决 java.sql.SQLSyntaxErrorException 异常

    java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax 错误 错误详情: Caused by: java.sql. ...

  8. java中JVM内存管理(1)

    Java岗位面试,JVM是对程序员基本功考察,通常会问你对JVM了解吗?  可以分几部分回答这个问题,首先JVM内存划分 | JVM垃圾回收的含义  |  有哪些GC算法  以及年轻代和老年代各自特点 ...

  9. Texture to texture2D以及texture2D像素反转

    private void SaveRenderTextureToPNG(Texture inputTex, string file) { RenderTexture temp = RenderText ...

  10. Unity C#数据持久化与xml

    最近工作需要用到数据持久化,所以在此分享一下,通过查阅资料,数据持久化大体都是通过xml或者json来进行的.unity为我们自定义了数据持久化方法,但是比较局限,还需要自己来完成数据持久化方法. ( ...