Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_77] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_77] at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_77] at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE] ... 21 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_77] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_77] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_77] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_77] ... 25 common frames omitted
解决方案:添加
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency>
删除其他依赖中的<scope>provided</scope>
8、源码地址
https://github.com/Genesisxu/SpringSeries/tree/master/SpringBoot-jsp
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
您可能感兴趣的文章: