Tomcat JDBC MySQL ClassNotFoundException [英] Tomcat JDBC MySQL ClassNotFoundException

查看:197
本文介绍了Tomcat JDBC MySQL ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的tomcat 7服务器上使用springMVC和JPA(使用hibernate)(在我的Mac上本地运行)。

I would like to use springMVC and JPA (using hibernate) on my tomcat 7 server (running locally on my Mac).

我能够设置所有成功使用嵌入式H2数据库。

I was able to set up everything successfully with an embedded H2 database.

现在我切换到mysql并收到以下错误消息:
$ b $

Now I switched to mysql and am getting the following error

java.lang.ClassNotFoundException: "com.mysql.jdbc.Driver"
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)

这表明tomcat正在查找Java的mysql连接器时遇到问题。
关于如何将连接器添加到$ CATALINA_HOME / lib中有很多教程。

This suggests tomcat is having trouble finding the mysql-connector for java. There are a multitude of tutorials on how to add the connector to $CATALINA_HOME/lib.

在尝试为我的项目使用maven依赖项后,建议并将.jar文件复制到lib目录中:

After trying to use a maven dependency for my project, I followed the advice and copied the .jar file into the lib directory:

$ ls $CATALINA_HOME/lib/mysql*.jar
/Users/david/Applications/tomcat/lib/mysql-connector-java-5.1.20-bin.jar

我已经读取并执行目录和文件的权限。

I have read and execute permissions on the directory and file.

目前我无法弄清楚如何让tomcat知道jar。该文件夹包含在

At the moment I can't figure out how to make tomcat aware of the jar. The folder is included in

$CATALINA_HOME/conf/catalina.properties

并且我已多次重新启动服务器。

and I have restarted the server multiple times.

感谢您的帮助。

推荐答案

通常情况下,CNFE的输出如下所示:

Normally, the output of a CNFE is as follows:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

而您的错误消息显示:

whereas your error message shows

java.lang.ClassNotFoundException: "com.mysql.jdbc.Driver"

我认为你的配置中的驱动程序类名仍然有引号。

I think you've still got quotes around the driver class name in your config.

这篇关于Tomcat JDBC MySQL ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆