…… are only available on JDK 1.5 and higher 错误
"C:\Program Files\Java\jdk1.8.0_73\bin\java" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:D:\softwares\idea\IntelliJ IDEA 2017.1\lib\idea_rt.jar=65398:D:\softwares\idea\IntelliJ IDEA 2017.1\bin" -Dfile.encoding=UTF-8 -classpath "D:\softwares\idea\IntelliJ IDEA 2017.1\lib\idea_rt.jar;D:\softwares\idea\IntelliJ IDEA 2017.1\plugins\junit\lib\junit-rt.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\classes;D:\softwares\idea\IntelliJ IDEA 2017.1\lib\junit-4.12.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\antlr-2.7.6.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\aspectjrt.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\aspectjweaver.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\c3p0-0.9.1.2.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\cglib-nodep-2.1_3.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\common-annotations.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\commons-collections-3.1.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\commons-fileupload-1.2.1.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\commons-logging-1.0.4.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\commons-logging.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\dom4j-1.6.1.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\ehcache-1.2.3.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\ejb3-persistence.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\freemarker-2.3.15.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\hibernate-annotations.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\hibernate-cglib-repack-2.1_3.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\hibernate-commons-annotations.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\hibernate-entitymanager.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\hibernate3.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\javassist-3.4.GA.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\jstl.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\jta-1.1.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\log4j-1.2.15.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\mysql-connector-java-3.1.13-bin.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\ognl-2.7.3.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\slf4j-api-1.5.2.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\slf4j-log4j12.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\spring.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\standard.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\struts2-core-2.1.8.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\struts2-spring-plugin-2.1.8.jar;F:\IntelliJProject\SSH2\WebRoot\WEB-INF\lib\xwork-core-2.1.6.jar;F:\ssh\SSH2\junit-4.8.2.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_73\jre\lib\rt.jar;F:\IntelliJProject\SSH2\junit-4.8.2.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 junit.test.EmployeeTest,list
log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [beans.xml]; nested exception is java.lang.IllegalStateException: Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at junit.test.EmployeeTest.setUpBeforeClass(EmployeeTest.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethodRepeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalStateException: Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
at org.springframework.context.config.ContextNamespaceHandler$1.parse(ContextNamespaceHandler.java:65)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
... 28 more
java.lang.NullPointerException
at junit.test.EmployeeTest.list(EmployeeTest.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner000(ParentRunner.java:58)
at org.junit.runners.ParentRunnerRepeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Process finished with exit code -1
1、在项目中创建一个package为org.springframework.core
2、在该package下面新建JdkVersion.java,内容如下:
package org.springframework.core; public abstract class JdkVersion { public static final int JAVA_13 = 0; public static final int JAVA_14 = 1; public static final int JAVA_15 = 2; public static final int JAVA_16 = 3; public static final int JAVA_17 = 4; //for jre 1.8 public static final int JAVA_18 = 5; private static final String javaVersion = System .getProperty("java.version"); private static final int majorJavaVersion; public static String getJavaVersion() { return javaVersion; } public static int getMajorJavaVersion() { return majorJavaVersion; } public static boolean isAtLeastJava14() { return true; } public static boolean isAtLeastJava15() { return getMajorJavaVersion() >= 2; } public static boolean isAtLeastJava16() { return getMajorJavaVersion() >= 3; } static { //for jre 1.8 if (javaVersion.indexOf("1.8.") != -1) { majorJavaVersion = 5; }else if (javaVersion.indexOf("1.7.") != -1) { majorJavaVersion = 4; } else if (javaVersion.indexOf("1.6.") != -1) { majorJavaVersion = 3; } else if (javaVersion.indexOf("1.5.") != -1) { majorJavaVersion = 2; } else { majorJavaVersion = 1; } } }
3、到项目的WEB-INF/classes 下面找到对应的package中的JdkVersion.class文件
4、将项目中的spring-core-2.5.6.jar拷贝出来打开,然后将JdkVersion.class替换jar包中的该文件。
5、将修改后的spring-core-2.5.6.jar再覆盖到项目中。
我是在第二步加入代码再次运行就OK了!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决