unsupported major.minor 52.0 Spring applicationContext.xml,context:component-scan标签

工程使用MAVEN 进行jar包管理,前期工程使用的是JDK1.7开发和编译的,因为业务需要,需要升级到JDK1.8,

当我将Maven编译插件的JDK版本由1.7修改为1.8时,如下图:

                          
				org.apache.maven.plugins
				maven-compiler-plugin
				3.6.0
				
					1.7
					1.7
					UTF-8
				
			

                         
				org.apache.maven.plugins
				maven-compiler-plugin
				3.6.0
				
					1.8
					1.8
					UTF-8
				
                        

我的MyEclipse2015  problems标签页总是出现一个错误,MyToken是我自定义的一个注解类。

java.lang.UnsupportedClassVersionError: com/xxx/xxx/xxx/MyToken : Unsupported major.minor version 52.0
查看我的MyEclipse2015的错误日志,显示如下:
java.lang.UnsupportedClassVersionError: com/xxx/xxx/xxx/MyToken : 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 java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:180)
	at org.springframework.asm.ClassReader.readAnnotationValues(ClassReader.java:1491)
	at org.springframework.asm.ClassReader.readMethod(ClassReader.java:909)
	at org.springframework.asm.ClassReader.accept(ClassReader.java:671)
	at org.springframework.asm.ClassReader.accept(ClassReader.java:508)
	at org.springframework.core.type.classreading.SimpleMetadataReader.(SimpleMetadataReader.java:64)
	at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:82)
	at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
	at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:277)
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
	at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:85)
	at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
	at org.springframework.ide.eclipse.beans.core.internal.model.namespaces.DelegatingNamespaceHandlerResolver$ElementTrackingNamespaceHandler.parse(DelegatingNamespaceHandlerResolver.java:192)
	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1424)
	at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1420)
	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1414)
	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
	at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ToolingFriendlyBeanDefinitionDocumentReader.doRegisterBeanDefinitions(BeansConfig.java:1350)
	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
	at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.registerBeanDefinitions(BeansConfig.java:404)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
	at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.loadBeanDefinitions(BeansConfig.java:388)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
	at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:447)
	at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:1)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:744)

明显这个错误是用高版本的JDK编译,在低版本的JDK上运行错误,因为我机器上面只安装了JDK1.8,所以工程相关的Bulid Path,window-->preferences-->java-->Installed JREs, window-->preferences-->java-->compiler的关于JDK的社设置都是一致的,所以感觉不能理解.工程放到TOMCAT8下运行也正常,只在 MyEclipse2015 里面报错。

后来在网上找到一篇文章,说是因为MyEclipse2015 工具运行的JDK环境有影响,我到  MyEclipse2015 的安装目录下找到myeclipse.ini 文件,打开一看,MyEclipse2015果然是运行在自带的JDK7上面,所以会出现以上错误,修改文件中的-vm参数如下:

-vm
C:\Program Files\Java\jdk1.8.0_92\bin\javaw.exe

重启MyEclipse2015后,重新编译工程,问题解决!

http://www.it1me.com/it-answers?id=33899430&ttl=Eclipse+(STS)+says+unsupported+major.minor+52.0+in+spring+file,+but+I'm+using+Java+8

点击打开链接,



你可能感兴趣的:(unsupported major.minor 52.0 Spring applicationContext.xml,context:component-scan标签)