spring中 asm 和 jdk版本不兼容的问题

前言:

  最近在学 spring,做相关demo测试时遇到一个问题

报错信息

  1. java.lang.IllegalArgumentException
  2. at org.springframework.asm.ClassReader.<init>(Unknown Source)
  3. at org.springframework.asm.ClassReader.<init>(Unknown Source)
  4. at org.springframework.asm.ClassReader.<init>(Unknown Source)
  5. at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:52)
  6. at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
  7. at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101)
  8. at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76)
  9. at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:298)
  10. at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300)
  11. at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300)
  12. at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:230)
  13. at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:153)
  14. at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:130)
  15. at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:285)
  16. at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)
  17. at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
  18. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
  19. at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
  20. at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
  21. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  22. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  23. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  24. at java.lang.reflect.Method.invoke(Unknown Source)
  25. at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  26. at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  27. at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  28. at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  29. at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
  30. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
  31. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
  32. at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  33. at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  34. at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
  35. at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
  36. at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
  37. at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  38. at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
  39. at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  40. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
  41. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
  42. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
  43. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

出错原因

  jdk版本不兼容,我用的是spring 3.2的版本,而 jdk的版本是 1.8

解决方法

  •   第一种:使用spring 4.0以上版本。
  •   第二种:使用jdk 1.7或以下版本

--------------------------------------------------MyEclipse 更改 jdk 版本分割线--------------------------------------------------------------------------------------

 

Window-->Preference-->java-->Installed JREs-->add-->Standard VM-->在JRE home中选择 JDK 的安装目录(注意:是 JDK 的安装目录

posted @ 2017-05-14 16:09  harryper  阅读(577)  评论(0编辑  收藏  举报