使用Servlet做登录验证功能时,启动Tomcat后,DAO层jdbc连接报错java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver
事先我确实忘记导入mysql-connector-java-x.x.x.jar
依赖了,但是导包之后重启tomcat,仍然报此错误
查找资料后发现原因是tomcat不会查找web项目下的依赖,而是查找自身lib目录的依赖
所以需要把jar包拷贝到tomcat/lib目录下
- Post link: http://example.com/2021/06/12/tomcat-jdbc%E6%8A%A5%E9%94%99ClassNotFoundException/
- Copyright Notice: All articles in this blog are licensed under unless otherwise stated.