Java 1.8 ASM ClassReader failed to parse class fil
Java 1.8 ASM ClassReader failed to parse class fil
miscellanea 发表于3年前
Java 1.8 ASM ClassReader failed to parse class fil
  • 发表于 3年前
  • 阅读 281
  • 收藏 1
  • 点赞 0
  • 评论 0

场景:

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.7.RELEASE</version>
</dependency>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<compilerVersion>1.8</compilerVersion>
<source>1,8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

编译打包后使用jetty-maven-plugin运行

抛错:

Caused by: 
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [F:\xxxxdevice\target\classes\com\xxx\controller\BaseController.class]; nested exception is 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 [F:\xxxxtdevice\target\classes\com\xxx\controller\BaseController.class]; nested exception is java.lang.IllegalArgumentException
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:290)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentR

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 [F:\xxxxdevice\target\target\classes\com\xxx\controller\BaseController.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)

原因jdk1.8编译过的类被Spring 3.2框架使用时不被Spring 3.2 支持

解决:降级jdk到1.7,或者升级Spring到4.0

参考:

http://stackoverflow.com/questions/22526695/java-1-8-asm-classreader-failed-to-parse-class-file-probably-due-to-a-new-java

共有 人打赏支持
粉丝 7
博文 71
码字总数 22525
×
miscellanea
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: