问题描述:运行项目时,报Exception in thread "main" java.lang.UnsupportedClassVersionError: com/ycy/common/annotation/BaseService : Unsupported major.minor version 52.0异常
如下所示:
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/ycy/common/annotation/BaseService : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.springframework.core.annotation.AnnotationAttributes.getAnnotationType(AnnotationAttributes.java:111)
at org.springframework.core.annotation.AnnotationAttributes.<init>(AnnotationAttributes.java:103)
at org.springframework.core.type.classreading.AnnotationAttributesReadingVisitor.<init>(AnnotationAttributesReadingVisitor.java:56)
at org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor.visitAnnotation(AnnotationMetadataReadingVisitor.java:88)
at org.springframework.asm.ClassReader.accept(ClassReader.java:658)
at org.springframework.asm.ClassReader.accept(ClassReader.java:523)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:64)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:98)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:93)
at org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:100)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:269)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.ycy.upms.rpc.YcyUpmsRpcServiceApplication.main(YcyUpmsRpcServiceApplication.java:17)
解决办法:
步骤:
1. 右键项目—>Properties—> java Compiler–>Compiler Compliance level
2. 选择自己安装的当前的JDK环境(我这里选择JDK8)即可
数字52的含义是:JDK8
各数字代表的含义:
JDK 8 = 52 (0x33 hex)
JDK 7 = 51 (0x33 hex),
JDK 6.0 = 50 (0x32 hex),
JDK 5.0 = 49 (0x31 hex),
JDK 1.4 = 48 (0x30 hex),
JDK 1.3 = 47 (0x2F hex),
JDK 1.2 = 46 (0x2E hex),
JDK 1.1 = 45 (0x2D hex).