Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter报错解决
报错:Caused by: java.lang.NoClassDefFoundError: javax/servlet/FilterCaused by: java.lang.NoClassDefFoundError: javax/servlet/Filterat java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_191]at
·
报错:
Caused by: java.lang.NoClassDefFoundError: javax/servlet/Filter
Caused by: java.lang.NoClassDefFoundError: javax/servlet/Filter
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_191]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_191]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_191]
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:158) ~[spring-core-5.0.12.RELEASE.jar:5.0.12.RELEASE]
... 23 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_191]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_191]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_191]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_191]
... 27 common frames omitted
原因:
有两个原因:(1)在maven中的作用域,不能是provided,需要是compile就是默认的scope(2)spring-boot-starter-tomcat的版本bug,换个新的或旧的版本试试
解决方法:
修改POM文件
注释掉< scope>provided< /scope>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--<scope>provided</scope> 注释掉-->
</dependency>
注释掉之后再运行就可以了。
更多推荐
已为社区贡献12条内容
所有评论(0)