Including external jar in Tomcat ClassPath

前端 未结 3 393
情话喂你
情话喂你 2020-12-06 04:47

In Tomcat I want to use a jar inside a web application. The jar file will exist outside of the Tomcat directory.

To include the jar file in tomcat classpath, I modi

相关标签:
3条回答
  • 2020-12-06 05:11

    I find myself copying extra JARs, which should be available for all contexts and should therefor go into the root loader, into the following directory:

     C:\Program Files\Apache Software Foundation\Tomcat 9.0\lib
    

    But this only possible if you have access to this directory, which might not be the case for all ISPs. At least you can do it at home.

    Bye

    0 讨论(0)
  • 2020-12-06 05:14

    I was using IntelliJ and I tried everything like:

    1. Using CtrlAltShiftS (Project Settings) and adding a dependency of mysql-connector.jar. Didn't work. (The only thing that worked was that code completion inside IntelliJ was working fine.
    2. Adding mysql-connector.jar to apache-home/lib/ folder. Didn't work.
    3. Including mysql-connector.jar from Maven inside IntelliJ. Just didn't work.

    The thing that worked for me:

    Include the mysql-connector.jar file in the PROJECT/web/WEB-INF/lib folder.

    No need to add it as a dependency anywhere. Just compile this and it will work fine.

    0 讨论(0)
  • 2020-12-06 05:19

    I figured myself how to add the classpath for tomcat. Instead of editing catalina.properties, just create a "setenv.sh" in the Tomcat Bin directory with the classpath,

    Example,

    CLASSPATH=D:\jaa\MyJarFile.jar
    

    I just checked the catalina.sh in Tomcat/bin and these classpath variable will be set while setting the bootstrap as the classpath.

    0 讨论(0)
提交回复
热议问题