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

后端 未结 13 2831
梦毁少年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:43

    What you should not do do (especially when working on a shared project)

    Ok, after had the same issue and after reading some answers here and other places. it seems that putting external lib into WEB-INF/lib is not that good idea as it pollute webapp/JRE libs with server-specific libraries - for more information check this answer"

    Another solution that i do NOT recommend is: to copy it into tomcat/lib folder. although this may work, it will be hard to manage dependency for a shared(git for example) project.

    Good solution 1

    Create vendor folder. put there all your external lib. then, map this folder as dependency to your project. in eclipse you need to

    1. add your folder to the build path
      1. Project Properties -> Java build path
      2. Libraries -> add external lib or any other solution to add your files/folder
    2. add your build path to deployment Assembly (reference)
      1. Project Properties -> Deployment Assembly
      2. Add -> Java Build Path Entries
      3. You should now see the list of libraries on your build path that you can specify for inclusion into your finished WAR.
      4. Select the ones you want and hit Finish.

    Good solution 2

    Use maven (or any alternative) to manage project dependency

提交回复
热议问题