_宁静 2017-05-08 11:18 采纳率: 100%
浏览 5279
已采纳

spring使用各种注解报错

使用Spring框架时,使用注解就报错.

 Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\Eclipse Luna4.4\eclipse\workspace\testWeb\build\classes\test\A.class]; nested exception is java.lang.IllegalArgumentException
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:56)
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
    at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:266)
    ... 24 more
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:53)
    ... 27 more

事情是这样的,本来使用eclipse4.6.1版本的,使用注释没有问题,后来写SpringMVC配置ok后启动tomcat就报错(不用注释),我就重新下了个4.4.2版本的eclipse,运行可以通过,但是现在发现,这个版本的eclipse使用注解就报错,包括注解注入、组件扫描等.请问这到底是什么问题,?

代码+jar包都是一样的.

  • 写回答

3条回答 默认 最新

  • _宁静 2017-05-08 13:42
    关注

    查了半天.发现是jdk与Spring不兼容导致的.我的是jdk8,用Spring4就解决问题了.遇到相同问题的兄弟不妨看看咯.避免去浪费不必要的时间

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?