Load external library in java web application

后端 未结 1 1752
执念已碎
执念已碎 2021-01-03 03:37

My scenario is the following:

I have a WebApp.war that is deployed to a servlet container. This WebApp.war contains in WEB-INF/lib the following libraries:

相关标签:
1条回答
  • 2021-01-03 03:50

    Since you are using Tomcat, you could leverage the VirtualWebappLoader.

    Add a META-INF/context.xml whith

    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/somepath/myapp">
        <Loader className="org.apache.catalina.loader.VirtualWebappLoader"
                  virtualClasspath="/somedir/*.jar"/>
    </Context>
    

    Remember also that the virtualClasspath attribute must be a absolute path, as correctly stated in the comment below.

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