• javax/servlet/ServletContext : Unsupported major.minor version 51.0


    原文:http://blog.csdn.net/mlin_123/article/details/50738532

    解决:将版本从 3.1.0 改为 3.0.1 

    <!-- 添加servlet API 依赖-->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.0.1</version>
    </dependency>

    进行 SpringJunit  测试时,报错:

    Java.lang.UnsupportedClassVersionError: javax/servlet/ServletContext : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method) 
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) 
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615) 
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) 
    at java.NET.URLClassLoader.defineClass(URLClassLoader.java:283) 
    at java.Net.URLClassLoader.access$000(URLClassLoader.java:58) 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 
    at java.lang.Class.getDeclaredConstructors0(Native Method) 
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2398) 
    at java.lang.Class.getConstructor0(Class.java:2708) 
    at java.lang.Class.getDeclaredConstructor(Class.java:1987) 
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:104) 
    at org.springframework.test.context.support.AbstractTestContextBootstrapper.instantiateListeners(AbstractTestContextBootstrapper.java:191)
    at org.springframework.test.context.support.AbstractTestContextBootstrapper.getTestExecutionListeners(AbstractTestContextBootstrapper.java:173)
    at org.springframework.test.context.TestContextManager.(TestContextManager.java:104) 
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:123)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.(SpringJUnit4ClassRunner.java:114) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31) 
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24) 
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) 
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29) 
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) 
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24) 
    at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:33) 
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:41) 
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) 
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

  • 相关阅读:
    【转载】八大排序算法
    【转载】算法的时间复杂度和空间复杂度的计算
    【转载】SpringMVC前台给后台传值的方式
    Session方法
    配置《算法 第四版》的Eclipse开发环境
    Learning Scrapy笔记(三)- Scrapy基础
    Learning Scrapy笔记(七)- Scrapy根据Excel文件运行多个爬虫
    Learning Scrapy笔记(六)- Scrapy处理JSON API和AJAX页面
    Scrapy Learning笔记(四)- Scrapy双向爬取
    Learning Scrapy笔记(五)- Scrapy登录网站
  • 原文地址:https://www.cnblogs.com/shihaiming/p/6703356.html
Copyright © 2020-2023  润新知