使用Spring5注解驱动开发时,出现以下bug:probably due to a new Java class file version that is supported yet 。
org.springframework.context.support.AbstractApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/cherriechenieth/Desktop/大数据开发/Spring5/demo1/out/production/aop/com/cherrychen/Tester.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 [/Users/cherriechenieth/Desktop/大数据开发/Spring5/demo1/out/production/aop/com/cherrychen/Tester.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 60
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/cherriechenieth/Desktop/大数据开发/Spring5/demo1/out/production/aop/com/cherrychen/Tester.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 [/Users/cherriechenieth/Desktop/大数据开发/Spring5/demo1/out/production/aop/com/cherrychen/Tester.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 60
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:452)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:315)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:276)
at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:295)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:249)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:206)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:174)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:89)
at com.cherrychen.Tester.main(Tester.java:15)
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 [/Users/cherriechenieth/Desktop/大数据开发/Spring5/demo1/out/production/aop/com/cherrychen/Tester.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 60
at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:60)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:49)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:429)
... 15 more
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 60
at org.springframework.asm.ClassReader.<init>(ClassReader.java:196)
at org.springframework.asm.ClassReader.<init>(ClassReader.java:177)
at org.springframework.asm.ClassReader.<init>(ClassReader.java:163)
at org.springframework.asm.ClassReader.<init>(ClassReader.java:284)
at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:57)
... 19 more
原因:JDK版本太高。 解决方案:
-
在官网重新下载JDK1.8版本:https://www.oracle.com/java/technologies/downloads/#java8-mac -
在idea里,选择file-project structure- project,在SDK处换成jdk1.8 -
重新运行程序
|