项目是一个maven项目,springboot版本用的是2.3.12.RELEASE,jdk用的7的版本,在单元测试类中执行,报错
"D:\Program Files\Java\jdk1.7.0_80\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:8130,suspend=y,server=n -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2020.3\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "D:\Program Files\JetBrains\IntelliJ IDEA 2020.3.1\lib\idea_rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2020.3.1\plugins\junit\lib\junit5-rt.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2020.3.1\plugins\junit\lib\junit-rt.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\jce.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\jfxrt.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\resources.jar;D:\Program Files\Java\jdk1.7.0_80\jre\lib\rt.jar;E:\Projects\example\cryptology\jcrypt\target\test-classes;E:\Projects\example\cryptology\jcrypt\target\classes;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\bouncycastle\bcprov-jdk15on\1.64\bcprov-jdk15on-1.64.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\boot\spring-boot-starter\2.3.12.RELEASE\spring-boot-starter-2.3.12.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\boot\spring-boot\2.3.12.RELEASE\spring-boot-2.3.12.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\spring-context\5.2.15.RELEASE\spring-context-5.2.15.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\boot\spring-boot-autoconfigure\2.3.12.RELEASE\spring-boot-autoconfigure-2.3.12.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\boot\spring-boot-starter-logging\2.3.12.RELEASE\spring-boot-starter-logging-2.3.12.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\spring-core\5.2.15.RELEASE\spring-core-5.2.15.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\spring-jcl\5.2.15.RELEASE\spring-jcl-5.2.15.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\boot\spring-boot-starter-web\2.3.12.RELEASE\spring-boot-starter-web-2.3.12.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\boot\spring-boot-starter-json\2.3.12.RELEASE\spring-boot-starter-json-2.3.12.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\com\fasterxml\jackson\core\jackson-databind\2.11.4\jackson-databind-2.11.4.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\com\fasterxml\jackson\core\jackson-annotations\2.11.4\jackson-annotations-2.11.4.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\com\fasterxml\jackson\core\jackson-core\2.11.4\jackson-core-2.11.4.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.4\jackson-datatype-jdk8-2.11.4.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.4\jackson-datatype-jsr310-2.11.4.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.4\jackson-module-parameter-names-2.11.4.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\boot\spring-boot-starter-tomcat\2.3.12.RELEASE\spring-boot-starter-tomcat-2.3.12.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.46\tomcat-embed-core-9.0.46.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.46\tomcat-embed-websocket-9.0.46.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\spring-web\5.2.15.RELEASE\spring-web-5.2.15.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\spring-beans\5.2.15.RELEASE\spring-beans-5.2.15.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\spring-webmvc\5.2.15.RELEASE\spring-webmvc-5.2.15.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\spring-aop\5.2.15.RELEASE\spring-aop-5.2.15.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\spring-expression\5.2.15.RELEASE\spring-expression-5.2.15.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\projectlombok\lombok\1.18.20\lombok-1.18.20.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\boot\spring-boot-starter-test\2.3.12.RELEASE\spring-boot-starter-test-2.3.12.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\boot\spring-boot-test\2.3.12.RELEASE\spring-boot-test-2.3.12.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\boot\spring-boot-test-autoconfigure\2.3.12.RELEASE\spring-boot-test-autoconfigure-2.3.12.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\com\jayway\jsonpath\json-path\2.4.0\json-path-2.4.0.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\net\minidev\json-smart\2.3.1\json-smart-2.3.1.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\net\minidev\accessors-smart\2.3.1\accessors-smart-2.3.1.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\assertj\assertj-core\3.16.1\assertj-core-3.16.1.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\hamcrest\hamcrest\2.2\hamcrest-2.2.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\junit\jupiter\junit-jupiter\5.6.3\junit-jupiter-5.6.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\junit\jupiter\junit-jupiter-api\5.6.3\junit-jupiter-api-5.6.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\junit\platform\junit-platform-commons\1.6.3\junit-platform-commons-1.6.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\junit\jupiter\junit-jupiter-params\5.6.3\junit-jupiter-params-5.6.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\junit\jupiter\junit-jupiter-engine\5.6.3\junit-jupiter-engine-5.6.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\junit\vintage\junit-vintage-engine\5.6.3\junit-vintage-engine-5.6.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\junit\platform\junit-platform-engine\1.6.3\junit-platform-engine-1.6.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\junit\junit\4.13.2\junit-4.13.2.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\mockito\mockito-core\3.3.3\mockito-core-3.3.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\net\bytebuddy\byte-buddy\1.10.22\byte-buddy-1.10.22.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\net\bytebuddy\byte-buddy-agent\1.10.22\byte-buddy-agent-1.10.22.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\objenesis\objenesis\2.6\objenesis-2.6.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\mockito\mockito-junit-jupiter\3.3.3\mockito-junit-jupiter-3.3.3.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\springframework\spring-test\5.2.15.RELEASE\spring-test-5.2.15.RELEASE.jar;D:\Software\Apache\Maven\apache-maven-3.6.3\repository\org\xmlunit\xmlunit-core\2.7.0\xmlunit-core-2.7.0.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 com.example.jcrypt.service.CryptoDemoTest,test
Connected to the target VM, address: '127.0.0.1:8130', transport: 'socket'
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/test/context/junit4/SpringRunner : 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 java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:432)
at sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:413)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:342)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:283)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:117)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3281)
at java.lang.Class.getAnnotation(Class.java:3229)
at com.intellij.junit4.JUnit4TestRunnerUtil.buildRequest(JUnit4TestRunnerUtil.java:145)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:47)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Disconnected from the target VM, address: '127.0.0.1:8130', transport: 'socket'
Process finished with exit code 1
降低spring-test的版本,笔者的项目并没有直接引入spring-test,那只能降低springboot的版本了,从2.3.12.RELEASE降到1.5.9.RELEASE。
为什么降到1.5.9.RELEASE呢?
因为1.5.9.RELEASE用的jdk的最低版本是1.6,而2.x的版本需要的jdk版本是1.8,且1.5.9是1.x的最高版本了。
直接用psvm 进行方法调用测试