javax.servlet.ServletException: Servlet执行抛出一个异常怎么解决?

站长亲测

  1. 数据库版本过高会导致报错 HTTP状态 500 – 内部服务器错误
  1. 如果未在webapp导入lib库会导致500报错
HTTP状态 500 - 内部服务器错误类型 异常报告消息 Servlet执行抛出一个异常描述 服务器遇到一个意外的情况,阻止它完成请求。例外情况javax.servlet.ServletException: Servlet执行抛出一个异常org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)根本原因。java.lang.NoClassDefFoundError: org/apache/ibatis/io/ResourcesRequest.LoginServlet.doGet(LoginServlet.java:29)javax.servlet.http.HttpServlet.service(HttpServlet.java:488)javax.servlet.http.HttpServlet.service(HttpServlet.java:582)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)根本原因。java.lang.ClassNotFoundException: org.apache.ibatis.io.Resourcesorg.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1420)org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1228)Request.LoginServlet.doGet(LoginServlet.java:29)javax.servlet.http.HttpServlet.service(HttpServlet.java:488)javax.servlet.http.HttpServlet.service(HttpServlet.java:582)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)):注意 主要问题的全部 stack 信息可以在 server logs 里查看Apache Tomcat/8.5.87
org.mybatismybatis3.5.5mysqlmysql-connector-java5.1.46
<" />version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>Maven-Mybatis-Servlet-Spring-0408</artifactId><version>1.0-SNAPSHOT</version><packaging>war</packaging><properties><maven.compiler.source>20</maven.compiler.source><maven.compiler.target>20</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><!--导入Servlet依赖坐标--><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version><!--此处为什么需要添加该标签?provided指的是在编译和测试过程中有效,最后生成的war包时不会加入 因为Tomcat的lib目录中已经有servlet-api这个jar包,如果在生成war包的时候生效就会和Tomcat中的jar包冲突,导致报错--><scope>provided</scope></dependency><!-- mysql坐标 --><!--<dependency>--><!--<groupId>mysql</groupId>--><!--<artifactId>mysql-connector-java</artifactId>--><!--<version>5.1.32</version>--><!--</dependency>--><!--mybatis 依赖--><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.5.5</version></dependency><!--mysql 驱动--><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.46</version></dependency><!--junit 单元测试--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.13</version><scope>test</scope></dependency><!-- 添加slf4j日志api --><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>1.7.20</version></dependency><!-- 添加logback-classic依赖 --><dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>1.2.3</version></dependency><!-- 添加logback-core依赖 --><dependency><groupId>ch.qos.logback</groupId><artifactId>logback-core</artifactId><version>1.2.3</version></dependency><dependency><groupId>org.apache.tomcat</groupId><artifactId>tomcat-websocket</artifactId><version>10.1.7</version></dependency><dependency><groupId>org.webjars.npm</groupId><artifactId>gulp-insert</artifactId><version>0.5.0</version></dependency></dependencies></project>