How to install JDBC driver in Eclipse web project without facing java.lang.ClassNotFoundexception

后端 未结 13 2830
梦毁少年i
梦毁少年i 2020-11-21 11:36

There is a VERY similar question to mine but in my case I don\'t have any duplicate jars in my build path, so the solution does not work for me. I\'ve searched google for a

13条回答
  •  灰色年华
    2020-11-21 11:39

    As for every "3rd-party" library in flavor of a JAR file which is to be used by the webapp, just copy/drop the physical JAR file in webapp's /WEB-INF/lib. It will then be available in webapp's default classpath. Also, Eclipse is smart enough to notice that. No need to hassle with buildpath. However, make sure to remove all unnecessary references you added before, else it might collide.

    An alternative is to install it in the server itself by dropping the physical JAR file in server's own /lib folder. This is required when you're using server-provided JDBC connection pool data source which in turn needs the MySQL JDBC driver.

    See also:

    • How to add JAR libraries to WAR project without facing java.lang.ClassNotFoundException? Classpath vs Build Path vs /WEB-INF/lib
    • How should I connect to JDBC database / datasource in a servlet based application?
    • Where do I have to place the JDBC driver for Tomcat's connection pool?
    • JDBC CLASSPATH Not Working

提交回复
热议问题