类路径,日食和java.lang.ClassNotFoundException:com.mysql.jdbc.Driver [英] classpath, eclipse and java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

查看:131
本文介绍了类路径,日食和java.lang.ClassNotFoundException:com.mysql.jdbc.Driver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过&阅读了10多个类似的问题,但仍然无法弄清楚.

I have seen & read over 10 similar questions but am still unable to figure it out.

我正在使用Windows7/Eclipse Helios Service Release 1/mysql-connector-java-5.1.13-bin.jar.

I am using windows7 / Eclipse Helios Service Release 1 / mysql-connector-java-5.1.13-bin.jar.

一切工作一直进行到昨天,现在我得到了这个错误. 我不知道我做过的任何事情可能会导致这种情况(但也许仍然...).

Everything worked until yesterday, and noW I get this error. I am not aware of anything I did that could have caused this (but maybe still...).

我的系统上没有此文件的副本(也不存在任何其他mysql-connector-*).

There are no duplicates of this file on my system (nor any other mysql-connector-*).

我不确定eclipse在哪里寻找此文件, 它与其他几个.jarS一起位于我的项目\WebContent\WEB-INF\lib文件夹下.

I am not sure where eclipse is looking for this file, it is sitting under my projects \WebContent\WEB-INF\lib folder with several other .jarS.

查看项目"菜单->属性,然后查看左侧的"Java Build Path",我将其视为库"选项卡内"Web应用程序库"下的库之一. 是否需要将其添加到CLASSPATH系统环境变量中? (如果是这样,那么在这种情况下会是什么?)

looking at the "project" menu -> properties and then "Java Build Path" on the left I see it as one of the libraries under "Web App Libraries" inside the "Libraries" tab. Do I need to add it to the CLASSPATH system environment variable ? (and if so - what would be . in that context ?)

有没有办法让我看到(通过调试)类加载器正在搜索的实际路径是什么?

is there a way for me to see (by way of debug) what is the actual path being searched by the class loader?

-=-=-
@javagirl

-=-=-
More info following comments by @javagirl

问::您从哪里获得例外的?编译,构建,作为Java应用程序运行,在tomcat/etc下运行?
A:是我在运行tomcat6的eclipse控制台上遇到的运行时异常.

Q: where did you get the exception? compilation, building, running as java app, under tomcat/etc running?
A: its a runtime exception I get on the eclipse console running tomcat6.

问:,您正在使用哪个构建工具,蚂蚁?
A: AFAIK无.只需按eclipse上的play或debug.并从浏览器连接到tomcat.

Q: which build tool are you using, ant?
A: AFAIK none. just press play or debug on eclipse. and connect to tomcat from a browser.

问::这个罐子位于最终构建的包装中吗?
A:我不知道该怎么回答,但是如果您能告诉我该看哪里,我会的.那就是说我猜答案是否定的,因为搜索仅找到我提到的JAR的单个实例.

Q: is this jar located in the final built package?
A: I don't know how to answer this, but if you can tell me where to look I will. that said I guess the answer is no because search only finds the single instance of the JAR I mentioned.

问::如果您在Tomcat容器(如tomcat)下运行它,则可能需要将其放在tomcat/lib文件夹中
A:我正在tomcat下运行-但不确定我应该在哪里实际找到此lib文件夹.

Q: if you running it under the servlet container like tomcat you probably need to put it in the tomcat/lib folder
A: I am running under tomcat - but not sure where I should actually find this lib folder.

-=-=-

有人可以指导我逐步解决这个问题吗?

can someone please guide me step by step with resolving this ?

推荐答案

因此,如果您在内置的tomcat下运行它:您可以转到工作空间文件夹(eclipseworkspace文件夹),其中将存在.metadata.plugins文件夹\ org.eclipse.wst.server.core \ tmp0(或tmp1,2-取决于您的环境)/wtpwebapps//WEB-INF/lib-应将应用程序的所有jar放在此处.如果没有,请尝试手动放置(但这是最糟糕的方法)

so if you are running it under built-in tomcat: you can go to your workspace folder (eclipse workspace folder), there will be folder .metadata.plugins\org.eclipse.wst.server.core\tmp0 (or tmp1,2 - depends on your environment)/wtpwebapps//WEB-INF/lib - here should be located all the jars of your app. If no - try to put it manually (but it's a worst way)

将其添加到tomcat lib文件夹-尝试找到它?当您在Eclipse中创建Server时,它应该询问您有关tomcat的安装文件夹?否则它可能会建议您下载它..所以只需下载/查找它,然后放在这个罐子里

to add it to tomcat lib folder - try to find it? when you create Server in the eclipse it should ask you about installation folder of your tomcat? or it can suggest download it.. so just download/find it, and put there this jar

ps:恐怕您需要阅读很多东西,例如,需要能够从命令行运行tomcat,以便更好地了解所有过程以及那里的工作方式.

ps: I afraid you need to read a lot of stuff, you need to be able run your tomcat from command line for example, to better understand all the process and how all is working there.

这篇关于类路径,日食和java.lang.ClassNotFoundException:com.mysql.jdbc.Driver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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