我正在用 java 开发一个 Web 应用程序,我试图使用 JDBC 模板(使用 springs dao)连接到 MySQL 数据库,但我总是得到:
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/DealingOfInsiders] threw exception [Request processing failed;
nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver '] with root cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
[....]
我认为问题来自包含目标类的文件 mysql-connector-java-5.1.25-bin.jar ......所以我尝试了很多方法来解决这个问题:
我已经用这个 jar 配置了我的项目的构建路径,但它没有用
我也把文件放在文件夹中:WEB-INF/lib,没用
我已经在 Eclipse 中为这个 jar 配置了一个类路径变量(preference ->java->buildpath->classpath 变量)它没有用
我已将 jar 文件放入 tomcat 库中,但效果不佳